diff --git a/Fibbonacci.java b/Fibbonacci.java new file mode 100644 index 00000000..093bb885 --- /dev/null +++ b/Fibbonacci.java @@ -0,0 +1,23 @@ +import java.util.Scanner; +public class Fibbonacci{ + + public static void main(String[] args) { + + int count, num1 = 0, num2 = 1; + System.out.println("How may numbers you want in the sequence:"); + Scanner scanner = new Scanner(System.in); + count = scanner.nextInt(); + scanner.close(); + System.out.print("Fibonacci Series of "+count+" numbers:"); + + int i=1; + while(i<=count) + { + System.out.print(num1+" "); + int sumOfPrevTwo = num1 + num2; + num1 = num2; + num2 = sumOfPrevTwo; + i++; + } + } +} \ No newline at end of file