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.
175
questions
6
votes
2answers
156 views
Fizzbuzz some Fibonacci numbers
I was teaching some new people in office a bit of COBOL, so I threw together this exercise where they had to write a program that would generate the first 10 numbers of a Fibonacci suite and then test ...
4
votes
2answers
3k views
A program to find out the number of odd and even Fibonacci numbers between given range
I built a program in C that can tell how many odd and even Fibonacci numbers there are between a given range.
Input Specification
First line of the input contains ...
0
votes
2answers
2k views
Coursera: Calculating sum of numbers in the fibonacci sequence between two specific points in the series
Question
This is an assignment for a Coursera course.
This is the algorithm I wrote.
...
3
votes
2answers
779 views
Finding the n th term in Fibonacci series
Solving a problem in coding contest I came across a problem, which on digging a bit lead me to the data set in this question . Since the program to enumerate and finding the solution was too complex ...
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.
...
3
votes
1answer
176 views
Fibonacci series - a different way
I am a C++ student (1.5 months into it). Please give feedback to this different way I have thought of for Fibonacci series. If there are any improvements needed, please suggest them also.
...
1
vote
1answer
2k views
Using 2 threads to compute the nth Fibonacci number (with memoization)
If the 5th Fibonacci number has to be computed, I'm trying to split the 2 recursive trees into 2 threads:
...
22
votes
1answer
659 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
1answer
172 views
Better Fibonacci sequence calculation
I attempted to make better Fibonacci sequence calculation algorithm in C++. This was the best I could:
...
9
votes
3answers
1k views
Find fibonacci series upto a given maximum in javascript
I'm attempting to find a fibonacci series where the last number is no greater than a given maximum. Given the start digits 1, 2
...
1
vote
1answer
212 views
Project Euler problem 2 in Haskell
I have just started Haskell, and I want to check if my code is following the spirit of the language.
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find ...
7
votes
4answers
7k 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:
...
1
vote
1answer
76 views
Sequence to extend and forget
After receiving some feetback about my previous attempt to create reusable, easily extendable sequence generators I try once again to create such a framework.
This time there is no inheritance. Just ...
3
votes
2answers
110 views
Sequence generators not only for potatoes but also for apples and oranges
The last question about sequence generators Growing potatoes in delayed sequences was only about potatoes. I thougt why not make it work with apples and oranges too so I made it generic.
The base ...
2
votes
1answer
117 views
Growing potatoes in delayed sequences
In order to grow potatoes I'm implementing the retry pattern. If I fail to grow them, I'd like to try it again later. The first part I've implemented is a collection of delay generators.
Their base ...
2
votes
1answer
1k views
Generating Fibonacci sequences in Scala
Would you consider this to be idiomatic Scala? If not, what would you do to improve it?
...
4
votes
2answers
2k views
Benchmarking inline vs normal functions in C++
I am currently learning C++ and have learnt about inline functions and how they can give a performance benefit.
How could this be improved?
...
3
votes
2answers
341 views
Zeckendorf Representation of positive integer
Zeckendorf's theorem states that all positive integers crepresented uniquely as the sum of one or more distinct Fibonacci numbers in such a way that the sum does not include any two consecutive ...
3
votes
2answers
1k views
Stack based non-recursive Fibonacci - Go implementation
The following function computes a the last element in a Fibonacci sequence in Go language.
...
3
votes
1answer
745 views
Modified Fibonacci method implementation - dynamic programming
I found this question on Hackerrank in dynamic programming:
Define a modified Fibonacci sequence as:
$$t_{n+2} = t_n + t_{n+1}^2$$
Given three integers, \$t_1\$, \$t_2\$, and \$n\$, compute ...
3
votes
3answers
1k views
Lucas sequence implementation
Could you suggest any improvements in this Lucas sequence's implementation:
...
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 ...
7
votes
6answers
2k views
Yet another Fibonacci number generator
First attempt at dynamic programming. I want to make this run faster and better.
fibonacci.cpp
...
2
votes
1answer
3k views
Nth Fibonacci number (Bottom-up with dict)
This is an algorithm that I wrote to get the nth Fibonacci number using bottom-up dictionary. How can I make this better/more efficient?
...
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 ...
2
votes
2answers
461 views
Fibonacci sequence methods
Decided to get a little JDK 8 practice in today, so I built two methods to print out the golden ratio, one uses the Stream API the other does not. Wanted to request general feedback on how well I ...
7
votes
2answers
1k views
Implement a generic Fibonacci sequence in Rust without using Copy trait
I'm trying to learn Rust and am a beginner. How does one go about implementing a generic version of the Fibonacci sequence without using Copy trait in Rust? My code ...
14
votes
3answers
1k views
Using Fibonacci sequence to generate musical melodies
I recently started picking up the Haskell programming language. I've managed to learn other languages rather quickly, but I'm still having a difficult time grasping some of the basics of Haskell.
I ...
1
vote
0answers
189 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 ...
6
votes
3answers
669 views
Wascally Wabbits
This question is part of a series solving the Rosalind challenges. For the previous question in this series, see Mendelian inheritance. The repository with all my up-to-date solutions so far can be ...
3
votes
1answer
2k views
Fibonacci Sequence in BrainF***
I have been trying to write a BrainF*** program that prints the Fibonacci sequence numbers repeatedly. I was wondering whether this is the most efficient way to do it. I basically repeatedly duplicate ...
3
votes
1answer
583 views
My C code for Fibonacci Sequence
I've been learning more programming in the past few years (C, Java, Arduino) for my hobbies. I read the "C for Dummies" book and found that it was good, but did not cover much - especially pointers... ...
1
vote
1answer
131 views
Select the element out of the array if its index is a Fibonacci number [closed]
I've some questions for an exam and wondered if somebody could take a look at my Fibonacci sequence that is supposed to answer this question:
"select the element out of the array if its index is a ...
6
votes
2answers
144 views
N-Bonnaci sequence calculator
The code calculates a n-bonnaci sequence to a certain number, based on the user's input. It then can print it to a file and/or print it to the console.
The ...
3
votes
1answer
1k views
Fibonacci using OOP methods in Java
I made a simple program that uses OOP methods. Please tell me if I used the 4 methods right. And if not, please show me how.
...
6
votes
1answer
185 views
Project Euler Q2 - Sum of even Fibonacci numbers
I'm very new at F#, and am using Project Euler to help me learn. Question #2 kept me going for a while, as my initial attempt at an answer was very slow and inelegant. Then I learnt about Seq.unfold, ...
12
votes
2answers
618 views
Dynamic Programming: Fibonacci-like recurrence relation
This is a problem from my Introduction to Algorithms textbook.
Consider the infinite sequence of numbers An|n>0 = (1,1,3,4,8,11,...) defined recursively as follows.
$$
A_n = \left\{\begin{aligned}
&...
8
votes
1answer
1k views
Let's “Iterator” through Fibonacci, forever and ever
Following-up to my previous question, this class is now based on an iterator. The class, instead of forcing the programmer to use up a bunch of memory just to get each progressive number once, they ...
11
votes
1answer
448 views
Fibonacci forever
I recently wrote a Fibonacci program in Python, and one of the answers mentioned an Infinite Sequence. I decided to implement an infinite sequence in Java, as I am not that experienced in Python.
<...
27
votes
2answers
670 views
Telling fibonaccis to the user
Though this program tells the truth (unless you change the source code), it does tell Fibonacci numbers, depending on the user's input. Keeping in mind of all (or most) of the feedback given from ...
0
votes
1answer
123 views
Fibonacci sequence and quadratic equation using functions [closed]
I know this code works, but is it correct to define them as functions or should I use something else?
...
6
votes
2answers
102 views
Data-structure exploration
On my quest to learn Ruby I figured exploring the proper usage of different data-structures would be invaluable, including strings, arrays and hashes.
I decided to build a hash containing the numbers ...
3
votes
2answers
519 views
Project Euler 25 - x-digit Fibonacci Number
I have solved the Problem 25 of the Euler Project:
The Fibonacci sequence is defined by the recurrence relation:
\$\qquad F_n = F_{n−1} + F_{n−2}\$, where \$F_1 = 1\$ and \$F_2 = 1\$.
...
13
votes
5answers
4k views
Simple Fibonacci using recursion
The sole purpose of this post is to see how a production quality developer would approach this very simple problem. I am a fresh graduate and do not have a professional development experience. What ...
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
2answers
328 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 ...
3
votes
2answers
203 views
Computing even huger Fibonacci numbers in Java
See the next iteration.
I have that method for computing Fibonacci numbers \$F_n\$ (\$n = 0, 1, 2, \dots)\$, that relies on computing
$$
A =
\begin{pmatrix}
1 & 1 \\
1 & 0
\end{pmatrix}^n.
$...
4
votes
2answers
2k views
Computing huge Fibonacci numbers in Java
I have this small Java program for computing particurly large Fibonacci numbers (10000th Fibonacci number is computed in about 220 milliseconds). The key idea here is to use lists of digits, which is ...
2
votes
1answer
541 views
Project Euler Problem 2 in Java
Each new term in the Fibonacci sequence is generated by adding the
previous two terms. By starting with 1 and 2, the first 10 terms will
be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By ...
5
votes
3answers
419 views
Outputting Fibonacci numbers
My program gets some input values and outputs Fibonacci values.
Generally, I'm adding single numbers from the right to left, and I'm saving it in the sum value and get rest of it and add to string. (...