Fibonaaci series help me with this code?
HEy @Nitya_Somani
correct code
import java.util.*;
public class Main {
public static void main(String args[]) {
// System.out.println(βHello World!β);
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int a = 0;
int b = 1;
int rows = 1;
while (rows <= n) {
int col = 1;
while (col <= rows) {
System.out.print(a + " ");
int sum = a + b;
a = b;
b = sum;
col++;
}
System.out.println();
rows++;
}
}
}
1 Like