Skip to content

Instantly share code, notes, and snippets.

@pepet96
Created January 20, 2014 23:58
Show Gist options
  • Save pepet96/8531817 to your computer and use it in GitHub Desktop.
Save pepet96/8531817 to your computer and use it in GitHub Desktop.
Fibonacci Sequence, cannot go further than 92
import java.util.Scanner;
import java.io.*;
public class Fibonacci {
public static void main (String [] args) {
long f = 0;
long n = 1;
Scanner input = new Scanner(System.in);
int x = input.nextInt();
for(int i=1; i<=x; i++) {
f = f + n;
n = f - n;
}
n = n;
f = f;
System.out.println(f);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment