Computer Science, asked by sassk4956, 7 months ago

write a menu driven program to print the Fibonacci series and print its sum

Answers

Answered by sneha2006bgp
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 aasthasahu0001
0

Explanation:

i Hope this answer is correct

Attachments:
Similar questions