diff --git a/Basics/FibonacciSeries.js b/Basics/FibonacciSeries.js new file mode 100644 index 0000000..d1d0baf --- /dev/null +++ b/Basics/FibonacciSeries.js @@ -0,0 +1,20 @@ +function fibonacciSeries(n) { + if (n <= 0) { + console.log("Please enter a positive integer."); + return; + } + + let a = 0, b = 1; + console.log("Fibonacci Series:"); + + for (let i = 1; i <= n; i++) { + console.log(a); + let next = a + b; + a = b; + b = next; + } +} + + +const n = 10; +fibonacciSeries(n); \ No newline at end of file