Computer Science, asked by irenerebeccamaria, 6 months ago

using switch statement write a menu driven program to display Fibonacci series till n​

Answers

Answered by pDivya24
2

Answer:

public class Fibonacci {

public static void main(String[] args) {

int n = 10, t1 = 0, t2 = 1;

System.out.print("First " + n + " terms: ");

for (int i = 1; i <= n; ++i)

{

System.out.print(t1 + " + ");

int sum = t1 + t2;

t1 = t2;

t2 = sum;

}

}

}

Similar questions