Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Name: Sean Myko C. Baang
- Section: CC11 - CCB
- Date: 07/18/2018
- */
- /*
- Description: Fibonacci Series...
- */
- import java.util.Scanner;
- class FibonacciProgram
- {
- public static void main(String args[])
- {
- Scanner reader = new Scanner(System.in);
- System.out.println("[FIBONACCI SERIES by Sean Baang]"); // Credits... hekhek...
- System.out.println(" ");
- System.out.println("[INPUT]: "); // char2 rani :)
- System.out.println(" ");
- int ctr = reader.nextInt(); // userinput....
- System.out.println(" ");
- System.out.println("[OUTPUT]"); // char2 rani :)
- System.out.println(" ");
- int x = 0;
- int y = 1;
- int z;
- int i;
- System.out.println(" " + x); // prints 0 because the fibonacci series starts with 0...
- System.out.println(" " + y); // prints 1...
- for(i = 2; i < ctr; ++i) // Loops starts here..
- {
- z = x + y;
- System.out.println(" " + z ); // print the fibonacci series...
- x = y;
- y = z;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement