Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class FibonacciNums
- {
- static void Main()
- {
- long N = long.Parse(Console.ReadLine());
- Fibonacci(0, 1, 1, N);
- }
- public static void Fibonacci(long a, long b, long counter, long N)
- {
- if (N >= 1 && N <= 50)
- {
- if (counter < N)
- {
- Console.Write(a + ", ");
- Fibonacci(b, a + b, counter + 1, N);
- }
- else if (counter == N)
- {
- Console.WriteLine(a);
- }
- }
- else
- {
- return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement