Last active
August 29, 2015 13:59
-
-
Save ganadist/10520283 to your computer and use it in GitHub Desktop.
simple fibonacci implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Fibonacci{ | |
public static void main(String []args){ | |
int start = Integer.parseInt(args[0]); | |
int fib1 = 0; | |
int fib2 = 1; | |
for(int i = 0; i <= (start -2); i++) { | |
int fib3 = fib1 + fib2; | |
System.out.println("F"+ i + " = " + fib1 + ", F" + (i+1) + " = " + fib2 + ", F" + (i+2) + " = " + fib3); | |
fib1 = fib2; | |
fib2 = fib3; | |
} | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment