Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package programmingexercises3;
- import java.util.Scanner;
- /**
- *
- * @author simongray
- */
- public class P416 {
- P416() {
- Scanner in = new Scanner(System.in);
- int n = in.nextInt();
- long fold1 = 1;
- long fold2 = 1;
- long fnew;
- for (int i = 0; i<n; i++) {
- System.out.println("#"+(i+1) +" fibonacci number: " + fold1);
- fnew = fold1 + fold2;
- fold2 = fold1;
- fold1 = fnew; }
- }
- }
Add Comment
Please, Sign In to add comment