0% found this document useful (0 votes)
3 views1 page

Shayan 2

Uploaded by

ayeshatoor2001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Shayan 2

Uploaded by

ayeshatoor2001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

int n = 10;

int a = 0, b = 1, c;
if (n <= 0)
Console.WriteLine("Please enter a positive integer.");
else {
Console.WriteLine("Fibonacci Series:");
Console.WriteLine(a);
Console.WriteLine(b);
for (int i = 2; i < n; i++) {
c = a + b;
Console.WriteLine(c);
sum += c;
a = b;
b = c;
}
Console.WriteLine($"The sum of the first {n} Fibonacci numbers is
{sum}.");

if (b <= 1)
Console.WriteLine("The last Fibonacci number is not prime.");
else
for (int i = 2; i <= Math.Sqrt(b); i++)
if (b % i == 0)
Console.WriteLine("The last Fibonacci number is not prime.");
else
Console.WriteLine("The last Fibonacci number is prime.");
end

You might also like