Skip to main content

All Questions

Filter by
Sorted by
Tagged with
7 votes
3 answers
2k views

Find the n-th Fibonacci number in O(log n) time

I was reading this website. It mentioned how to use matrix exponents to find the n-th Fibonacci number in O(log n) time. I tried implementing it Python along with a fast exponent algorithm. I'm not ...
Justin Cheng's user avatar
-3 votes
1 answer
234 views

Calculate the sum of even Fibonacci numbers

This is my solution for problem 2 of Project Euler using Python: ...
Amir Motefaker's user avatar
7 votes
1 answer
234 views

A Python 3 script that generates art using matplotlib

I am always super interested in both science and art, science and art are two different ways to describe the objective reality, they are two sides of the same coin, in many areas they overlap, and ...
Ξένη Γήινος's user avatar
2 votes
1 answer
311 views

Python functions that calculate first n terms of a given order of Fibonacci sequences

I have written two functions that calculate the first n terms of a given order o of Fibonacci sequence, and return the result as ...
Ξένη Γήινος's user avatar
2 votes
1 answer
495 views

Project Euler Problem #755

As the title indicates this is one of the last most problems of Project Euler. The problem is straightforward. However, similar to the rest of the Euler Project problems either ...
Lady Be Good's user avatar
1 vote
3 answers
198 views

Fibonacci generator python implementation

I wrote this code for a fibonacci sequence generator. Can anyone tell me whether my code is designed well? if not, why? ...
Malemna's user avatar
  • 21
2 votes
2 answers
385 views

Cython Fibonacci Sequence

For my current job, I've been told that soon I'm going to be porting our Python code to Cython, with the intent of performance upgrades. In preparation of that, I've been learning as much about Cython ...
Ben A's user avatar
  • 10.7k
5 votes
2 answers
1k views

Fibonacci sequence output

Here's the code I'm having trouble shortening. I am currently a beginner in Python 3.x. ...
Lolfaceftw's user avatar
4 votes
2 answers
1k views

Recursive vs. non-recursive implementations of Fibonacci sequence

I have 2 functions to get the n-th fibonacci number. The 1st one uses recursive calls to calculate the power(M, n), while the 2nd function uses iterative approach for power(M, n). Theoretically (at ...
NepNep's user avatar
  • 301
5 votes
5 answers
2k views

Asking for Fibonacci numbers, up till 50

I am learning Python, and this is one of the program assignments I have to do. I need to write code to prompt user to enter Fibonacci numbers continuously until it's greater than 50. If everything ...
ThangNguyen's user avatar
0 votes
1 answer
109 views

Fibonnaci sequence calculation [closed]

Below are two ways to calculate an element of the Fibonacci series. Can someone please help me understand why fib1 is so much faster (over 60x) than ...
psyco's user avatar
  • 3
16 votes
5 answers
6k views

Project Euler # 25 The 1000 digit Fibonacci index

The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 ...
user avatar
4 votes
4 answers
5k views

Find the nth term of a sequence that consists of Fibonacci and prime numbers interleaved

I have given a series problem 1,2,1,3,2,5,3,7,5.... in which the odd terms forms the Fibonacci series and even terms form the prime number series. I have to write a code in which I have to find the ...
coderina's user avatar
  • 155
10 votes
8 answers
7k views

Python program for fibonacci sequence using a recursive function

A Fibonacci sequence is the integer sequence of 0, 1, 1, 2, 3, 5, 8..... The first two terms are 0 and ...
Justin's user avatar
  • 2,599
3 votes
3 answers
658 views

Calculate the nth Fibonacci number, mod m

I was trying to output F(n) mod m to find the remainder of Fibonacci number, where F(n) could be a very big number: ...
djriles's user avatar
  • 33

15 30 50 per page