Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- public List<int> Fibonacci(int limit)
- {
- int a = 0;
- int b = 1;
- boolean found=false;
- List<int> forreturn = new List<int>();
- while(!found)
- {
- int temp = a;
- a = b;
- b = temp + b;
- a < limit ? forreturn.add(a) : found=true;
- }
- return forreturn;
- }
- static void Main()
- {
- boolean success = false;
- int limit = 0;
- while(!success)
- try { limit = int.Parse(Console.Readline());
- success=true;
- }
- Console.Writeline();
- foreach( int i in Console.WriteLine(Fibonacci(limit)))
- {
- Console.Write(i," , ");
- }
- }
- }
Add Comment
Please, Sign In to add comment