Skip to main content

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.

Filter by
Sorted by
Tagged with
2 votes
3 answers
2k views

A FibonacciSequenceGenerator in C# looking for speed improvements. Currently generates 1 million numbers in 25.6 seconds. We must use BigInteger because the ...
Short Int's user avatar
  • 782
1 vote
2 answers
345 views

I have a piece of code that attempts to reduce the work and span in making a Fibonacci sequence. My approach is to parallelize the code as much as possible, along with doing matrix multiplication and ...
Droid's user avatar
  • 119
7 votes
3 answers
2k views

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 ...
Justin Cheng's user avatar
2 votes
1 answer
149 views

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 ...
DisplayName's user avatar
0 votes
1 answer
177 views

My function accepts a number, which generates total Fibonacci numbers. I am using recursion. Please follow the code below, ...
Rahul Shivsharan's user avatar
-2 votes
1 answer
254 views

This is my solution for problem 2 of Project Euler using Python: ...
Amir Motefaker's user avatar
1 vote
3 answers
232 views

I have written a code below for printing the first n fibonacci numbers, the code is as follows ...
Rahul Shivsharan's user avatar
7 votes
1 answer
246 views

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 ...
Ξένη Γήινος's user avatar
3 votes
1 answer
885 views

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 ...
NPN328's user avatar
  • 791
1 vote
1 answer
258 views

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\$ ...
Ξένη Γήινος's user avatar
2 votes
1 answer
330 views

I have written two functions that calculate the first n terms of a given order o of Fibonacci sequence, and return the result as ...
Ξένη Γήινος's user avatar
3 votes
1 answer
135 views

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 ...
William Bradley's user avatar
2 votes
1 answer
522 views

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 ...
Lady Be Good's user avatar
1 vote
1 answer
106 views

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 ...
fluffyyboii's user avatar
1 vote
3 answers
234 views

I wrote this code for a fibonacci sequence generator. Can anyone tell me whether my code is designed well? if not, why? ...
Malemna's user avatar
  • 21
2 votes
2 answers
393 views

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 ...
Ben A's user avatar
  • 10.8k
1 vote
1 answer
423 views

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 ...
KGE's user avatar
  • 11
9 votes
3 answers
2k views

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 ...
user4035's user avatar
  • 303
1 vote
2 answers
1k views

...
Ilija Ivic's user avatar
6 votes
2 answers
1k views

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 ...
William Bradley's user avatar
1 vote
1 answer
619 views

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 ...
Geoff's user avatar
  • 111
5 votes
2 answers
1k views

Here's the code I'm having trouble shortening. I am currently a beginner in Python 3.x. ...
Lolfaceftw's user avatar
5 votes
4 answers
2k views

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? <...
Km Shrikanth's user avatar
3 votes
1 answer
199 views

File fibonacci.aec: ...
FlatAssembler's user avatar
3 votes
3 answers
1k views

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 ...
UnfreeHeX's user avatar
  • 173
4 votes
2 answers
1k views

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 ...
NepNep's user avatar
  • 301
3 votes
2 answers
346 views

I've implemented the following Fibonacci iterator: lib.rs ...
Matias Cicero's user avatar
5 votes
5 answers
2k views

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 ...
ThangNguyen's user avatar
6 votes
1 answer
129 views

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 ...
slepic's user avatar
  • 5,657
0 votes
1 answer
98 views

Task: Return the fibonacci value at a given index. e.g: input: 6, return: 8. Algorithm 1: ...
Elya Livshitz's user avatar
0 votes
1 answer
127 views

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 ...
psyco's user avatar
  • 3
3 votes
1 answer
122 views

I am implementing a Fibonacci range in C++17 such that it supports ...
Christopher Boo's user avatar
2 votes
2 answers
156 views

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 ...
pacmaninbw's user avatar
  • 26.2k
12 votes
2 answers
1k views

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 ...
JsonDork's user avatar
  • 414
16 votes
5 answers
6k views

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 ...
user avatar
4 votes
4 answers
5k views

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 ...
coderina's user avatar
  • 155
10 votes
8 answers
7k views

A Fibonacci sequence is the integer sequence of 0, 1, 1, 2, 3, 5, 8..... The first two terms are 0 and ...
Justin's user avatar
  • 2,619
3 votes
3 answers
689 views

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: ...
djriles's user avatar
  • 33
2 votes
1 answer
400 views

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 ...
Brandon's user avatar
  • 119
4 votes
2 answers
2k views

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, ...
Michael Choi's user avatar
4 votes
1 answer
240 views

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 ...
Alex Lopatin's user avatar
3 votes
0 answers
445 views

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 ...
olooney's user avatar
  • 131
2 votes
2 answers
233 views

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: <...
antoniu200's user avatar
0 votes
2 answers
1k views

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 ...
user avatar
12 votes
2 answers
4k views

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: ...
Armando Pérez Marqués's user avatar
0 votes
1 answer
2k views

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 ...
TheQult's user avatar
  • 268
1 vote
2 answers
115 views

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 ...
mvr950's user avatar
  • 297
7 votes
2 answers
4k views

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 ...
N_H1922's user avatar
  • 237
6 votes
2 answers
242 views

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 ...
user avatar
1 vote
1 answer
161 views

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 ...
nookyi's user avatar
  • 21