# Questions tagged [fibonacci-sequence]

The Fibonacci sequence is the sequence defined by F(0) = 0, F(1) = 1, F(n + 2) = F(n) + F(n + 1). The first few terms are 0, 1, 1, 2, 3, 5, 8.

193 questions
Filter by
Sorted by
Tagged with
2k views

### Find the n-th Fibonacci number in O(log n) time

I was reading this website. It mentioned how to use matrix exponents to find the n-th Fibonacci number in O(log n) time. I tried implementing it Python along with a fast exponent algorithm. I'm not ...
• 317
1 vote
127 views

### Fibonacci calculator

I'm trying to learn Rust and for this reason I'm reading the Rust Book. It contains the following exercise: Generate the nth Fibonacci number. Here's my take. Note I'm only using material from ...
139 views

### Can I optimize my implementation of generating Fibonacci series using recursion?

My function accepts a number, which generates total Fibonacci numbers. I am using recursion. Please follow the code below, ...
208 views

### Calculate the sum of even Fibonacci numbers

This is my solution for problem 2 of Project Euler using Python: ...
1 vote
180 views

### Printing the first n numbers of the Fibonacci sequence

I have written a code below for printing the first n fibonacci numbers, the code is as follows ...
172 views

### A Python 3 script that generates art using matplotlib

I am always super interested in both science and art, science and art are two different ways to describe the objective reality, they are two sides of the same coin, in many areas they overlap, and ...
• 3,086
1 vote
747 views

### Functional Fibonacci in OCaml

I'm very new to OCaml, and as an exercise I decided to implement the nth Fibonacci algorithm (return a specific Fibonacci number, given an index) in different ways, using what I've learned so far. I ...
• 761
1 vote
209 views

### JavaScript function that generates Fibonacci like sequences of given order

Generalizations of Fibonacci numbers Fibonacci numbers of higher order A Fibonacci sequence of order $n$ is an integer sequence in which each sequence element is the sum of the previous $n$ ...
• 3,086
283 views

### Python functions that calculate first n terms of a given order of Fibonacci sequences

I have written two functions that calculate the first n terms of a given order o of Fibonacci sequence, and return the result as ...
• 3,086
106 views

### Iterative Fibonacci number generator in Kotlin

I have very limited experience in Java and slightly more in C# (just doing Advent of Code problems last month), so I'm not familiar with how to write idiomatic Kotlin. This class implements an ...
469 views

### Project Euler Problem #755

As the title indicates this is one of the last most problems of Project Euler. The problem is straightforward. However, similar to the rest of the Euler Project problems either ...
• 177
1 vote
78 views

### Generating the N-bonacci numbers

I'm new to Haskell, and this is one of the more interesting programs I've made with it so far. I understand there are already solutions to this problem that use much less code, but to me this one ...
• 113
150 views

### Fibonacci generator python implementation

I wrote this code for a fibonacci sequence generator. Can anyone tell me whether my code is designed well? if not, why? ...
• 11
344 views

### Cython Fibonacci Sequence

For my current job, I've been told that soon I'm going to be porting our Python code to Cython, with the intent of performance upgrades. In preparation of that, I've been learning as much about Cython ...
• 10.1k
1 vote
354 views

### Fibonacci sequence array in Javascript

This is my third day of learning Javascript through an online class. I learned about arrays and while/for loops today, and to practice all of that stuff the challenge I'm working on is to make a ...
• 11
2k views

### n-th Fibonacci number with memoization

I am learning Rust and decided to create a simple program to calculate n-th Fibonacci number. It uses a vector for memoization. The program works, but what would you suggest to improve here? Maybe ...
• 293
1 vote
1k views

...
1k views

### C++17 Recursive Fibonacci calculation with memoization

Compiler is g++ 4.2. I'm new to C++, but I've done a lot of data science, web scraping, and some socketing stuff in Python. This code generates the nth Fibonacci number, either with a naive ...
1 vote
510 views

### MASM) assembly implementation of recursive Fibonacci

I'm trying to teach myself assembly via MASM, below is my first implementation of the recursive form of the fibonacci sequence. I timed it against an equivalent C implementation in release mode and ...
• 111
1k views

### Fibonacci sequence output

Here's the code I'm having trouble shortening. I am currently a beginner in Python 3.x. ...
2k views

### A Fibonacci series

I am having trouble with time and complexity analysis. I have done a fibonacci series in a recursive way. I think it is O(n2). Can you find out the time analysis? If possible, could you elaborate it? <...
169 views

### Fibonacci Sequence using Recursion with Memoisation

File fibonacci.aec: ...
977 views

### Fibonacci series

I have written the following code for my 1st year project, the Fibonacci series. I programmed it without searching Google. Is my code good enough to get me an A or a B? Can I make the code more ...
• 173
1k views

### Recursive vs. non-recursive implementations of Fibonacci sequence

I have 2 functions to get the n-th fibonacci number. The 1st one uses recursive calls to calculate the power(M, n), while the 2nd function uses iterative approach for power(M, n). Theoretically (at ...
• 301
305 views

### Fibonacci iterator

I've implemented the following Fibonacci iterator: lib.rs ...
1k views

### Asking for Fibonacci numbers, up till 50

I am learning Python, and this is one of the program assignments I have to do. I need to write code to prompt user to enter Fibonacci numbers continuously until it's greater than 50. If everything ...
• 153
85 views

### Fibonacci and Lucas sequence generator using Boost and GMP

I implemented this console application that generates Fibonacci and Lucas sequence numbers using boost and GMP for multiprecision. There is an iterator-like class which can do any sequence based on ...
• 5,467
75 views

### Choosing between 2 Fibonacci alternatives [closed]

Task: Return the fibonacci value at a given index. e.g: input: 6, return: 8. Algorithm 1: ...
99 views

### Fibonnaci sequence calculation [closed]

Below are two ways to calculate an element of the Fibonacci series. Can someone please help me understand why fib1 is so much faster (over 60x) than ...
100 views

### Implement Fibonacci range

I am implementing a Fibonacci range in C++17 such that it supports ...
122 views

### Get the Nth Term in the Fibonacci Sequence

I'm trying out a new editor (CLion) and I decided to try an old well known programming problem. I also decided to try out C99 rather than C89. This program calculates the nth term of the Fibonacci ...
• 23.8k
1k views

### Calculating Fibonacci sequence in several different ways

I'm doing an experiment trying to freshen up my unit-testing and learn dynamic programming. Every test passes but I'm curious of the result of some of them and worried if I'm doing the testing ...
• 414
6k views

### Project Euler # 25 The 1000 digit Fibonacci index

The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 ...
5k views

### Find the nth term of a sequence that consists of Fibonacci and prime numbers interleaved

I have given a series problem 1,2,1,3,2,5,3,7,5.... in which the odd terms forms the Fibonacci series and even terms form the prime number series. I have to write a code in which I have to find the ...
• 155
7k views

### Python program for fibonacci sequence using a recursive function

A Fibonacci sequence is the integer sequence of 0, 1, 1, 2, 3, 5, 8..... The first two terms are 0 and ...
• 2,489
621 views

### Calculate the nth Fibonacci number, mod m

I was trying to output F(n) mod m to find the remainder of Fibonacci number, where F(n) could be a very big number: ...
• 33
368 views

### Fibonacci sequence binary tree console logger

I wrote code to show the structure of a Fibonacci sequence pattern in a graphical way. First I structure a tree given a variable the user inputs for how many iterations of the sequence they want to ...
• 123
2k views

### Foobar Challenge: Lovely Lucky Lambs

I've been able to reduce my solution to constant time. Is it possible to reduce this by any constant factor further? (Besides trivialities i.e. inserting constants, not lazy importing). Specifically, ...
• 159
201 views

### Time(n) Complexity of Fibonacci Algorithms

It is my first use of classes in Python. I wanted to create something useful and try some new things as I learn this cool language: strategy pattern, testing with nanoseconds precision, curve/poly ...
• 141
412 views

### Calculate huge Fibonacci Numbers in C++ using GMP and boost::multiprecision

Problem Statement Calculate the exact value of the n-th Fibonacci number, say the one-billionth. Algorithm The algorithm is based on the idea that Fibonacci numbers can be represented as 2x2 ...
• 131
153 views

### Write in file the n-th term in iccanobiF series

Siruri2 | www.pbinfo.ro Fibonacci, a famous Italian mathematician in the Mediaeval Era, had discovered a series of natural numbers with multiple applications, a string that bears his name: <...
• 159
1k views

### Fibonacci Nth term using tail recursion [closed]

I have created a program that prints the Nth term of the Fibonacci sequence. The fib function needs to use tail recursion. If what I have coded isn't tail recursion, I would like to know how to change ...
4k views

### Recursive Fibonacci in Rust with memoization

I'm trying to come up with an "elegant" way of calculating Fibonacci for number in Rust, using recursion and memoization (self-imposed requirements). This is what I have so far: ...
2k views

### Javascript Fibonacci with dynamic programming

Trying to applying what seen on What Is Dynamic Programming and How To Use It (here: https://www.youtube.com/watch?v=vYquumk4nWw ) Obviuously this is the final code, after removing the recursion. I ...
• 268
1 vote
82 views

### Output string length and classical Fibonacci sequence in a web page

I wrote a JavaScript and XHTML webpage. I think the format of the output is not better or the validation process is not as it is supposed to be. How can I improve the code? How can I make it more ...
• 297
4k views

### alternating Fibonacci and prime series

The task is to print the following series 1 2 1 3 2 5 3 7... The elements at odd positions are Fibonacci series terms and the elements at even positions are ...
• 237
218 views

### Project Euler #2 with a fibSequence and result

I have a background in Linguistics and my journey as an aspiring developer has just begun. I was hoping you could give me a feedback on the solution I have come up with for the second challenge of ...
1 vote
142 views

### Display Fibonacci numbers

I just started coding programs with python. As a challenge I wanted to program something to print out the Fibonacci Numbers. It looks like I've done what I wanted to do (I checked the first few ...
• 21