Beware
New member
- Joined
- Jun 13, 2023
- Messages
- 2
- Programming Experience
- Beginner
C#:
namespace Trening
{
internal class Program
{
static void Main(string[] args)
{
int fiboBroevi = 10;
int[] fibo = new int[fiboBroevi];
fibo[0] = 0;
fibo[1] = 1;
// sumaPar = sumEven, sumaNepar = sumOdd
int sumaPar = 0;
int sumaNepar = 0;
for (int i = 2; i < fiboBroevi; i++)
{
fibo[i] = fibo[i - 1] + fibo[i - 2];
}
foreach (int broj in fibo)
{
if (broj % 2 == 0)
{
sumaPar += broj;
}
else
{
sumaNepar += broj;
}
}
Console.WriteLine( sumaPar);
Console.WriteLine( sumaNepar);
}
}
}
Last edited by a moderator: