Fibonacci Java algorithm for the tangent sequence __c language

Source: Internet
Author: User
/* Fibonacci series refers to such a series:
1,1,2,3,5,8,13,21 ...
The series was originally raised about the number of rabbits, that is: a pair of rabbits, if they are adults in the second month after their birth,
The third month has reproductive capacity, and the reproductive ability of a pair of rabbits every one months have a pair of rabbits. Set the birth of a
All the rabbits were one female and one male, and none died. Ask a newborn pair of rabbits how many pairs of rabbits can reproduce in a year.
The principle is: The month of the rabbit logarithm equals last month's rabbit logarithm plus this month born rabbit logarithm; and this month out
The rabbit logarithm is equal to the monthly reproductive ability of the rabbit logarithm, that is equal to the first two months of the rabbit logarithm. That is, nth
The moon after the rabbit logarithm FN, is in the first one months of the existing rabbit logarithm fn-1 based on the increase in the logarithm is
The monthly reproductive ability of the rabbit logarithm, it equals two months before the rabbit logarithm fn-2, so we have
Fn=fn-1+fn-2
*
*/

public class Fibonacci
{
public static void Main (string[] args)
{
Initializing variables
int n0 = 1, n1 = 1, n2;

System.out.print (N0 + "" + n1 + "");

Introduce a For loop to execute three expressions sequentially, and limit I to the range of <10
for (int i = 0; i < i++)
{
The next number is the previous two number and
N2 = n1 + n0;

System.out.print (n2 + "");

The first number of previous numbers became the previous second number
N0 = N1;
At the same time the current number becomes the previous number
N1 = n2; and current number becomes previous
}
System.out.println (); Terminate the line
}
}

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.