nth Fibonacci

Run Settings
LanguageJava
Language Version
Run Command
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("Enter the nth position you want"); int x = in.nextInt(); int a = 0; int b = 1; int count = 2; while(count <= x){ int temp = b; b += a; a = temp; count++; } System.out.println(b); } }
Editor Settings
Theme
Key bindings
Full width
Lines