Fibonacci Series

ma’am,
here is the code I wrote while practicing Fibonacci Series , is this approach also correct ?

//

import java.util.Scanner;

public class FibonacciSeries {

public static void main(String[] args) {

	Scanner scn = new Scanner(System.in);
	int n = scn.nextInt();

	int i = 0;
	int b = 1;
	int a = 0;
	int sum;

	System.out.println(a);
	System.out.println(b);

	while (i <= n - 2) {

		sum = a + b;
		System.out.println(sum);
		a = b;
		b = sum;

		i = i + 1;
	}

}

}

//

It is working and giving the right outputs
Please tell

yes this is right :slight_smile: