Last active
January 25, 2018 18:15
-
-
Save sayham-sjb/9329fb67a569b9f8550b5a7990f81e4c to your computer and use it in GitHub Desktop.
fibonacci #java #VS
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
Private static int index = 0; | |
public static void main (String[] args){ | |
int n1 = 0; | |
int n2 = 1; | |
System.out.println(“index: “ + index + “ = “ + n1); | |
fibonacci(n1, n2); | |
} | |
public static void fibonacci(int n1, int n2){ | |
System.out.println(“index: “ + index + “ = “ + n2); | |
if (index == 20){ //Stopping point. | |
return; | |
} | |
index++; //Make sure to increment our index to walk towards the end. | |
fibonacci(n2, n1 + n2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment