Каждое последующее число ряда Фибоначчи — это сумма двух предыдущих чисел.
0 1 1 2 3 5 8 13 21 34 …
0 1 1 2 3 5 8 13 21 34 …
Main.cs
usingSystem;classProgram {-
publicstaticintMain() { -
Console.Write("Введите конец диапазона от 1 до : "); -
intend=int.Parse(Console.ReadLine()); -
intj=1; -
for(inti=1; i<=end; i+=j) { -
Console.Write("{0} ", i); -
j=i-j; -
} -
Console.ReadKey(); -
return0; -
} }
usingSystem;classProgram {-
publicstaticintMain() { -
Console.Write("Введите конец диапазона от 1 до : "); -
intend=int.Parse(Console.ReadLine()); -
intj=1; -
for(inti=1; i<=end; i+=j) { -
Console.Write("{0} ", i); -
j=i-j; -
} -
Console.ReadKey(); -
return0; -
} }
Введите конец диапазона от 1 до : 25
1 1 2 3 5 8 13 21
1 1 2 3 5 8 13 21