Skip to main content
8 votes
1 answer
252 views

Fast calculation of Nth generalized Fibonacci number of order K?

How can I calculate Nth term in Fibonacci sequence of order K efficiently? For example, Tribonacci is Fibonacci order 3, Tetranacci is Fibonacci order 4, Pentanacci is Fibonacci order 5, and Hexanacci ...
Ξένη Γήινος's user avatar
3 votes
2 answers
228 views

Is it possible to use the closed-form of Fibonacci series to generate the Nth Fibonacci number exactly and efficiently?

The closed-form of the Fibonacci series is the following: As you can see the expression contains square roots so we cannot use it directly to generate Nth Fibonacci number exactly, as sqrt(5) is ...
Ξένη Γήινος's user avatar
0 votes
1 answer
99 views

How to make Excel do a different operation in A2 depending on what type of number A1 is?

These operations take priority: If A1 Prime: subtract previous prime (if 1 treat as odd number) If A1 Perfect Square: square root While these are the conditions if those aren't true: If A1 Even: ...
Carlo's user avatar
  • 1
1 vote
3 answers
127 views

How to return the sum of the two previous numbers?

I want to write a function that returns a number based on the fibonacci rule where each new number returned is based on the sum of the two previous numbers 1, 1, 2, 3, 5, etc. So if the user inputs 4, ...
lunarchild's user avatar
1 vote
2 answers
90 views

Why is there such large variation in computation time for Fibonacci generation between adjacent values of n?

Each method is getting large variations in computation time, even with lots of repeats (to obtain a mean). The effect appears to get worse with larger n. This is my timing code. def timeBlock(func, n,...
Lockyli's user avatar
  • 19
1 vote
2 answers
159 views

SICP exercise 1.19, transformations

From Structure and Implementation of Computer Programs, second edition: Exercise 1.19: There is a clever algorithm for computing the Fibonacci numbers in a logarithmic number of steps.Recall the ...
Tina Russell's user avatar
4 votes
3 answers
255 views

How to use all CPU threads when calculating Fibonacci number?

Question: I have a program that calculates the Fibonacci number. When I set a large number of passes, it runs extremely slow because it only works with 1 CPU core, I want to know how to make it ...
user29362427's user avatar
1 vote
2 answers
103 views

Number of ways to reach A to B by climbing one step, two steps or three steps at a time

I was solving a test on an online platform and the problem statement was similar to this. Stuart has to go from one place to other (A-> B) and he can jump either 1 step, 2 step or 3 steps at a time....
ABGR's user avatar
  • 5,263
1 vote
1 answer
83 views

Recursive Fibonacci Assembly

i´ve written a code in assembly that recursively calculates the fibonacci sequence for a number. the code is for a RISC V processor. The code works correctly for the numbers 1 and 2 but everything ...
Ali Yildiz's user avatar
0 votes
0 answers
39 views

Calculating Fibonacci Sequence to 46 times or more in 8086 Assembly [duplicate]

I'm learning 8086 assembly through college course and i ran into a problem. I'm trying to calculate Fibonacci sequence to 46 places but 16-bits registers inside this processors can't handle large ...
Crisiroid's user avatar
-1 votes
3 answers
195 views

My class doesn't generate a Fibonacci sequence properly

I'm trying to make a class that generates a Fibonacci sequence. My two modules are below, the fibonacci.py module and the test_fibonacci.py module. The first two tests pass but the third one seems to ...
JSO's user avatar
  • 21
1 vote
2 answers
122 views

Computing the nth Fibonacci number using forward recursion with memoization

Question: Is it possible to compute the nth Fibonacci number using forward recursion with memoization? If so, how? If not, why not? Context: Most learning resources and books (e.g., CLRS, DPV, etc.) ...
Daniel W. Farlow's user avatar
0 votes
0 answers
58 views

Issues with array size outputting garbage values in assembly

I am using x86 assembly MASM to compute first 41 fibonacci numbers. I initially had an array set to size 41, with 0's. This causes correct output for first 10ish values, with remaining indices being ...
newGuy77's user avatar
-1 votes
1 answer
100 views

Fibonacci script

I have this Fibonacci script #!/bin/bash if (test $# -ne 1) then echo "Use: $0 number" exit 1 fi for c in ‘seq 1 $1‘ do if (($c == 1)) then n0=1; echo "fibonacci(1)=$n0"; ...
Gigi's user avatar
  • 111
0 votes
1 answer
77 views

Trying to get the nth Fibonacci number but always gives me 2^nth

I tried to solve Fibonacci series problem in rust, but unfortunately it always return me exponent of 2^n. Here is my code: use std::io; // Fibonacci Series Number // F(n) = 1,1,2,3,5,8,13,....(n-1),((...
Farhan Mushtaque's user avatar

15 30 50 per page
1
2 3 4 5
159