Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Mason Marnell
- class Fibo {
- public static void main(String[] args) {
- long fibo[] = new long[30];
- fibo[0] = 1;
- fibo[1] = 1;
- // make a for loop
- // let the current fibo equal the sum of the previous 2
- for(int j = 2; j < fibo.length; j++){
- fibo[j] = fibo[j-1] + fibo[j-2];
- }
- for (int i = 0; i < fibo.length; i++) {
- System.out.println(fibo[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement