Guest User

Untitled

a guest
Dec 3rd, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.52 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package programmingexercises3;
  6.  
  7. import java.util.Scanner;
  8.  
  9. /**
  10.  *
  11.  * @author simongray
  12.  */
  13. public class P416 {
  14.     P416() {
  15.     Scanner in = new Scanner(System.in);
  16.     int n = in.nextInt();
  17.     long fold1 = 1;
  18.     long fold2 = 1;
  19.     long fnew;
  20.    
  21.     for (int i = 0; i<n; i++) {
  22.         System.out.println("#"+(i+1) +" fibonacci number: " + fold1);
  23.         fnew = fold1 + fold2;
  24.         fold2 = fold1;
  25.         fold1 = fnew;   }
  26.     }
  27. }
Add Comment
Please, Sign In to add comment