Skip to main content

All Questions

Filter by
Sorted by
Tagged with
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 ...
Togepi's user avatar
  • 127
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 ...
Ozymandias's user avatar
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 ...
R Hamilton's user avatar
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. ...
Enzio's user avatar
  • 123
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: ...
Siddhartha's user avatar
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 ...
jusexton's user avatar
  • 696
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. ...
eshi's user avatar
  • 33
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} &...
Legato's user avatar
  • 9,929
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 ...
TheCoffeeCup's user avatar
  • 9,516
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. <...
TheCoffeeCup's user avatar
  • 9,516
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 ...
sophist_pt's user avatar
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 ...
coderodde's user avatar
  • 31.3k
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. $...
coderodde's user avatar
  • 31.3k
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 ...
coderodde's user avatar
  • 31.3k
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 ...
Dust_In_The_Wind's user avatar

15 30 50 per page