All Questions
Tagged with fibonacci-sequence java
26 questions
1
vote
1
answer
470
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 ...
1
vote
4
answers
2k
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 ...
3
votes
1
answer
532
views
Fibonacci generating algorithm
I have written an algorithm that generates a Fibonacci series to the \$Nth\$ number. The code below works fine, but as a beginner I know I must be writing pretty ugly code.
For example I think it is ...
0
votes
2
answers
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.
...
1
vote
1
answer
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:
...
2
votes
2
answers
545
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 ...
3
votes
1
answer
2k
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.
...
12
votes
2
answers
647
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
1
answer
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
1
answer
485
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.
<...
13
votes
5
answers
5k
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 ...
3
votes
2
answers
479
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
2
answers
249
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
2
answers
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
1
answer
730
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 ...