Recursion-Fibonacci Sequence

Source: Internet
Author: User

Describe
The
Fibonacci sequence refers to the series: the first and second numbers of the series are 1, followed by each number equal to the sum of the preceding 2 numbers.
Give a positive integer a, which requires the number of a in the Fresnel sequence.
Input
Line 1th is the number of groups of test data n, followed by n-line input. 1 rows per set of test data, including a positive integer a (1 <= a <=)
Output
the output has n rows, and each line of output corresponds to one input. The output should be a positive integer, the size of number A in the Fibonacci sequence
Sample input
452191
Sample output
5141811
I heard that this series is a formula, but the slag will not, only slowly recursion
Code
#include<cstdio>#include<iostream>UsingNamespace Std;int RE[23]={0};IntF(int x){int IJK, l; re[1]=1; re[2]=1;For(I=3; I<=23; I+ +) re[I]=re[I-2]+re[I-1];Return0;}//Building TableIntMain(){F(1);int a[25]={0},N(0), IJK; Cin>>n;for (I=0;i<n;i++) Cin>>a[i]; For (I=0;i<n;i++) cout< <re[a[i]]<<endl return 0;}   

Recursive-Fibonacci sequence

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.