Advertisement
MnMWizard

Untitled

Nov 6th, 2017
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. //Mason Marnell
  2. class Fibo {
  3.  
  4.  
  5. public static void main(String[] args) {
  6.  
  7. long fibo[] = new long[30];
  8. fibo[0] = 1;
  9. fibo[1] = 1;
  10.  
  11. // make a for loop
  12. // let the current fibo equal the sum of the previous 2
  13. for(int j = 2; j < fibo.length; j++){
  14. fibo[j] = fibo[j-1] + fibo[j-2];
  15. }
  16.  
  17.  
  18. for (int i = 0; i < fibo.length; i++) {
  19. System.out.println(fibo[i]);
  20.  
  21. }
  22. }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement