From f99bb9150b7c27b635b5d2f5e21986fd7536ea16 Mon Sep 17 00:00:00 2001 From: namanhere23 Date: Thu, 30 Oct 2025 21:59:40 +0530 Subject: [PATCH] Add Fibonacci series implementation --- Basics/FibonacciSeries.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Basics/FibonacciSeries.js 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