/***//**
* Fractionserial. Java
* There is a fractional sequence: 2/1, 3/2, 5/3, 8/5, 13/8, 21/13...
* Calculate the sum of the first 20 items of the series.
* @ Author Deng Chao (codingmouse)
* @ Version 0.2
* Development/test environment: jdk1.6 + eclipse SDK 3.3.2
*/
Pub
# Include
}/* The numerator behind the score is equal to the numerator plus the denominator of the previous score, and the denominator of the subsequent score is equal to the numerator with the previous score */
There is a fractional sequence: 2/1, 3/2, 5/3, 8/5, 13/8, 21/13
There is a fractional sequence of 2/1 + 3/2 + 5/3 + 8/5 + 13/8 +... Find the sum of the first 20 items of the series.Program:
# Include
Output result: 32.660261 Press any key to continue
C language: There is a score sequence: 2/1 + 3/2 + 5/3 + 8/5 + 13/8 +... Find the sum of the first 20 items in this seriesProgram:
# Include
Output result: 32.660261 Press any key to continue
In order to omit the space and make it visible to the operator who manually fills in the paper, the volume number on the card of the materials shelf is determined to be classified and sorted, as shown in
A-3, A-4, A-5, A-8 forming A-3 ~ 5, 8, etc.
The following code uses a few auxiliary list
/// /// Similar to 1, 2, 3, 5, 7, 8, 10, 11, 12, 13, 14, 15, 16, 21, 22
Vector used: # include # Include Using namespace STD;
Int fenshu (INT );
Int main ()
{
Double sum = 0, sum1 = 0;
For (INT I = 2; I {
Sum1 + = fenshu (I );
}
Sum = sum1 + 0.5;
Cout Return 0;
}
Int fenshu (INT index)
{
Double temp;
Vector A. Reserve (3 );
A. At (0) = 1;
A. at (1) = 2;
For (INT I =
The Fibonacci Sequence, also known as the Golden series. In mathematics, the Fibonacci series are defined as follows by recursive Methods: F0 = 0, F1 = 1, Fn = F (n-1) + F (n-2) (n> = 2, in modern physics, quasi-crystal structure, chemistry, and other fields, the Fibonacci series are directly applied. Now, from an algo
/**/
/// /// The rule for a column number is as follows: 1, 1, 2, 3, 5, 8, 13, 21, and 34 calculate the number of 30th digits, which is implemented using a recursive algorithm. (C # language) /// /// ///
Public
Int
Getnumberatpos (
Int
Pos)
{ If (Pos = 0 | Pos =
Class Recursion{Static void main (string [] ARGs){Int result;Recursion rc = new recursion ();Result = RC. recursioncal (30 );Console. Write ("the result: {0}", result );
}
Private int recursioncal (int I){Int result;If (I {Result = 1;}
Another solution:
Using system;Public class huoqushu{Public static void main (){Console. writeline (fanhui (30 ));}Public static int fanhui (int I){If (I {Return 0;}If (I> 0 I {Return
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.