Files
c-sharp/Fibonacci/Program.cs

33 lines
873 B
C#
Raw Permalink Normal View History

2022-04-05 18:15:07 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Fibonacci {
internal class Program {
2022-04-27 10:48:53 +02:00
/*public static ulong fibonacci(int darab) {
2022-04-05 18:15:07 +02:00
if ((darab == 0) || (darab == 1)) {
return Convert.ToUInt64(darab);
} else {
return fibonacci(darab - 1) + fibonacci(darab - 2);
}
2022-04-27 10:48:53 +02:00
}*/
2022-04-05 18:15:07 +02:00
static void Main(string[] args) {
Console.WriteLine("Adja meg hány számot akar látni");
ulong darab = Convert.ToUInt64(Console.ReadLine());
ulong a = 0, b = 1, szamlalo = 0;
while (szamlalo++ < darab) {
b += a;
a = b - a;
Console.WriteLine(b);
}
Console.ReadKey();
}
}
}