write a menu driven program to print the Fibonacci series and print its sum
Answers
Answered by
2
Answer:// Java program to print first n Fibonacci Numbers
class Test
{
// Method to print first n Fibonacci Numbers
static void printFibonacciNumbers(int n)
{
int f1 = 0, f2 = 1, i;
if (n < 1)
return;
for (i = 1; i <= n; i++)
{
System.out.print(f2+" ");
int next = f1 + f2;
f1 = f2;
f2 = next;
}
}
// Driver Code
public static void main(String[] args)
{
printFibonacciNumbers(7);
}
}
Answered by
0
Explanation:
i Hope this answer is correct
Attachments:
Similar questions
Social Sciences,
3 months ago
Math,
3 months ago
Biology,
7 months ago
Math,
11 months ago
English,
11 months ago