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
23
votes
1answer
641 views

BF welcomes Fibonnaci

Slightly inspired by a previous question/april fools joke I decided to take on Fibonnaci sequence in the lovely language Brainfuck. In order to do this I have also worked on Brainduck, which is a ...
7
votes
4answers
6k views

Project Euler problems 1 and 2 in python

What do you think about my code? I am a beginner and just started doing some algorithmic exercises to sharpen up my python skills. Here is code for problem #1: ...
3
votes
1answer
48 views
3
votes
0answers
57 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 ...
3
votes
2answers
830 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 ...
4
votes
2answers
751 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 ...
4
votes
5answers
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 ...
2
votes
2answers
77 views

Fibonacci iterator

I've implemented the following Fibonacci iterator: lib.rs ...
4
votes
1answer
716 views

Python3 Terminal Based 'Combat' System

This is my first leap into Python and I had a lot of fun writing this - it is not complete yet. I'm interested in adding a perk system next, instead of generically increasing stats I'd like the ...
0
votes
1answer
61 views

Choosing between 2 Fibonacci alternatives [closed]

Task: Return the fibonacci value at a given index. e.g: input: 6, return: 8. Algorithm 1: ...
0
votes
1answer
91 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 ...
3
votes
1answer
35 views

Implement Fibonacci range

I am implementing a Fibonacci range in C++17 such that it supports ...
2
votes
2answers
97 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 ...
4
votes
2answers
901 views

Huge Fibonacci modulo m optimization in Python 3

I'm doing some an Algorithm Design online course as a way of learning algorithms and Python as well. One of these challenges requires that I write code for finding a "Huge Fibonacci Number Modulo m". ...
15
votes
5answers
3k 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 ...
12
votes
2answers
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 ...
4
votes
4answers
2k 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 ...
10
votes
8answers
4k 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 ...
3
votes
3answers
250 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: ...
5
votes
5answers
4k views

Finding large Fibonacci Number in Python

I'm doing Project Euler at 1000-digit Fibonacci number - Problem 25 which says The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. ...
2
votes
1answer
170 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 ...
4
votes
2answers
1k 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, ...
6
votes
4answers
2k views

Sum of even Fibonacci numbers

So, in my first attempt I created a code that generated all fibonacci numbers and appended to a list. This list I then traversed to get the even numbers and added them up. It worked, but took like 5 ...
4
votes
1answer
124 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 ...
6
votes
6answers
2k views

Calculating Fibonacci numbers

The following problem is currently taking more than 8 seconds to execute. Please help me to modify the program, so that execution time will be reduced. ...
3
votes
0answers
158 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 ...
6
votes
4answers
18k views

Fibonacci sum with memoization

Problem: Using the recursion approach, find a Fibonacci sum without repetition of computation. ...
2
votes
2answers
110 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: <...
3
votes
1answer
86 views

Iterative Fibonacci sequence

I implemented a function that prints all the numbers from the Fibonacci sequence until max_num. The minimum value allowed is 0 (so, fib(0) prints 1). It works until ...
7
votes
1answer
167 views

Better Fibonacci sequence calculation

I attempted to make better Fibonacci sequence calculation algorithm in C++. This was the best I could: ...
3
votes
1answer
258 views

Fibonacci calculator in Haskell

I'm just starting to look into Haskell. I've written a naive Fibonacci implementation, and I've also written a more advanced one that uses tail-call recursion for efficiency. ...
0
votes
2answers
538 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 ...
7
votes
1answer
1k 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: ...
0
votes
1answer
918 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 ...
7
votes
2answers
3k 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 ...
1
vote
2answers
69 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 ...
5
votes
2answers
200 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
1answer
119 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 ...
6
votes
3answers
2k views

Performance of dynamic Fibonacci generator and dead rabbits

I would like to improve my code style and its efficiency. I'm just moving beyond the standard recursive approach to a lot of simple algorithms. This post has two code snippets with slightly ...
5
votes
1answer
800 views

Dynamic Fibonacci algorithm in x86 (MASM)

My task was to implement this algorithm that uses memoization to calculate fibonnaci numbers: ...
1
vote
0answers
164 views

Over-engineered fizzbuzz

I've got this fizzbuzz project I am using for a blog series, among other things. In this version, the fizzbuzz function is fed from a Fibonacci generator. I'm particularly concerned with the ...
1
vote
1answer
371 views

Recursive Fibonacci in Java

I just started learning recursion and memoization, so I decided to give a simple implementation a shot. Works with some simple test cases I came up with. Is there anything I can add to make this more ...
-5
votes
2answers
848 views

9 ways to generate Fibonacci numbers in C++

This is C++ code that consists of 9 different functions that generate Fibonacci numbers. Although all functions display same result, the emphasis is on practice to use different methods or ways. I ...
1
vote
4answers
1k views

Improving Fibonacci recursion with BigIntegers

I've been tasked with making a fast Fibonacci recursive method that uses BigInteger to calculate REALLY big numbers. However, to calculate numbers past 30 it takes ...
10
votes
3answers
2k views

Table of Tribonacci sequence using NumPy and PANDAS

What I am trying to accomplish is calculate the Tribonacci numbers and the ratio. I can do this in Excel easy like this. So I tried do the same using Python 3 now. It works and gives such output. ...
4
votes
1answer
282 views

Memoizing in PostScript

The pusherr and poperr procedures maintain an internal stack as a lisp-like linked-list. It's a little slower than an earlier ...
3
votes
2answers
305 views

Computing even huger Fibonacci numbers in Java - follow-up

See the previous and initial iteration. I have incorporated almost all the suggestions by Peter Taylor: The actual method returns a BigInteger instead of ...
1
vote
1answer
336 views

Name scope for memoization Fibonacci [closed]

Here's a snippet of code I use to examine the functionality of Python decorator(@memorize). An example of Fibonacci computation: ...
8
votes
1answer
1k views

Fibonacci in linear time by using an extra pointer

I have a function to find the nth number in a Fibonacci sequence, in which I am recursively calling the function. The sum is stored in a class variable and I have an extra pointer I increment every ...
12
votes
6answers
4k views

Python 3 - Fibonacci Implementation

I wrote a function returning the n-th Fibonacci number in Python 3: ...