Advertisement
almooh

Fibonacci Number

Apr 15th, 2017
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Fibonacci
  4. {
  5.     public static void main(String args[])
  6.     {
  7.         Scanner input = new Scanner(System.in);
  8.        
  9.         System.out.println("Welcome to Fibonacci Program!");
  10.         System.out.print("\nEnter a number: ");
  11.         long num = input.nextLong();
  12.        
  13.         long fibonacciNumber = findFibonacci(num);
  14.        
  15.         System.out.println("\nThe fibonacci number of " + num + " is " + fibonacciNumber + ".");
  16.         if(num > 1426)
  17.             System.out.println("Sorry! The maximum allowed number is 1426.");
  18.     }
  19.    
  20.     static long findFibonacci(long n)
  21.     {
  22.         if(n == 0)
  23.             return 0;
  24.         else if(n == 1)
  25. ...............................
  26.  
  27. Downlode full project from Here :::
  28.  
  29.  
  30. http://tmearn.com/NwCx
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement