Linked Questions

0 votes
2 answers
505 views

Fibonacci Recursion Not working [duplicate]

I probably made some stupid mistake, but whenever I try to run this program it always gives me a wrong answer. For example, I ask what is the 5th value of the Fibonacci sequence and it says 7. ...
joshugqa's user avatar
0 votes
1 answer
363 views

Learning Java - Do not fully understand how this sequence is calculated (Fibonacci) [duplicate]

I am learning Java and I have this code from the internet and running it in Eclipse: public class Fibonacci { public static void main (String [] args) { for (int counter = 0; counter &...
John's user avatar
  • 15
-2 votes
1 answer
105 views

Fibonacci Sequence How is it Working [duplicate]

I am confused as to how Java is running this specific code. I am comfortable with the Fibonacci sequence but not exactly with how to grapple my mind to the way this specific method is running. So ...
Esteban Barajas's user avatar
24 votes
10 answers
59k views

Fast Fibonacci recursion

I'm trying to recall an algorithm on Fibonacci recursion. The following: public int fibonacci(int n) { if(n == 0) return 0; else if(n == 1) return 1; else return fibonacci(n - 1) + ...
ducin's user avatar
  • 26.6k
3 votes
4 answers
29k views

How to write Fibonacci Java program without using if [closed]

What is the code to write in int Fibonacci (int n) without using "if" like they did here Java recursive Fibonacci sequence ? I tried to write this but it is wrong : Because in this program the list ...
K Mass's user avatar
  • 53
2 votes
3 answers
2k views

find the sum of all the numbers in the Fibonacci series that are smaller or equal to that number

The Fibonacci numbers are the numbers in the following integer sequence. 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144 . . . Given a specific number in this series Fn, your program needs to find the ...
Kushal Jain's user avatar
  • 3,196
1 vote
4 answers
2k views

Recursive Fibonacci using BigInteger in Java [duplicate]

I'm trying to solve a project euler 25 problem in java and since I need something to store numbers with 10000 digits, I'm using BigInteger classes. So I'm working in some recursive fibonacci sequence ...
Gabriel Augusto's user avatar
1 vote
2 answers
328 views

F# Understanding the Fibbonacci Sequence Recursively

This might sound like a School assignment but it is not! I have made a recursive function returning a value from the Fibonacci Sequence. let rec FoneFive n = match n with | 1 | 2 -> 1 ...
Nulle's user avatar
  • 1,329
0 votes
1 answer
1k views

Repeating A Function From Within A Function In Python 3

My question is that I was writing a program in Python 3 trying to think of a way to repeat a function from within a function, when on StackOverflow I found I can do this with the else statement: def ...
jediquest1's user avatar
0 votes
2 answers
339 views

Debugging my recursive Fibonacci Java code and correcting the logic

I'm unable to understand why the output is wrong. I've tried to write a recursive code of printing Fibonacci numbers and got the expected output and a stream of unexpected values. public class ...
AzharKhaji's user avatar
-1 votes
3 answers
325 views

Java 1 student totally lost. Recursion program

Hi very first Java class and it seems to be going a mile a minute. We learn the basics on a topic and we are asked to produce code for more advanced programs than what helped us get introduced to the ...
mbish75's user avatar
  • 21
1 vote
2 answers
173 views

java library similar to c++ map

To find nth fibonacci number using memoization I found one code which uses map in c++. I have tried to convert this code in java but it fails . code in c++: #include <bits/stdc++.h> ...
priyank's user avatar
  • 35
1 vote
2 answers
100 views

Recursive function to calculate 25% of the sum of what is returned before

I'd like to write a recursive function that returns a double and takes an int as input. If input == 1, return 1. If input == 2 the function must return 1.25 (the sum of what was previously returned, ...
ominofelice's user avatar
0 votes
3 answers
130 views

I am trying to solve recursion by hand

I am self taught and thought that I understood recursion, but I can not solve this problem: What is returned by the call recur(12)? What is returned by the call recur (25)? public static int recur ...
Texasteach's user avatar
-4 votes
3 answers
118 views

Need to explain with Fibonacci

I have seen many examples of Fibonacci here on Stack Overflow but I have found no answer for my question. So, I have a code: public class Fib { public static int fib(int n) { if (n < 2)...
Vit Rasmussen's user avatar