1007,1007 Printer Driver
Fibonacci count
Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 347 Accepted: 248
Description
The infinite series, 21, 34, 55... is called the Fibonacci series, which can be recursively defined
F (n) = 1 ...... (n = 1 or n = 2)
F (n) = F (n-1) + F (n-2)... (n> 2)
I want you to calculate the nth Number of fepona. (1st and the second are both 1)
Input
The first row is an integer m (m <5), indicating a total of m groups of test data.
Each test data has only one row and only one integer n (n <20)
Output
The first row is an integer m (m <5), indicating a total of m groups of test data.
Each test data has only one row and only one integer n (n <20)
Sample Input
3135
Sample Output
125
Source
Typical questions
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace AK1007 { class Program { static void Main(string[] args) { int[] fib = new int[25]; fib[1] = 1; fib[2] = 1; for (int i = 3; i < 21; i++) fib[i] = fib[i - 1] + fib[i - 2]; int n = int.Parse(Console.ReadLine()); while (n-- > 0) { int x = int.Parse(Console.ReadLine()); Console.WriteLine(fib[x]); } } } }
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger. Welcome to share your nice codes!