Questions tagged [fibonacci-sequence]

The Fibonacci sequence is the sequence defined by F(0) = 0, F(1) = 1, F(n + 2) = F(n) + F(n + 1). The first few terms are 0, 1, 1, 2, 3, 5, 8.

159 questions
147 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 ...
2k 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 ...
95 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: ...
51 views

Fibonacci sequence binary tree console logger

I wrote code to show the structure of a Fibonacci sequence pattern in a graphical way. First I structure a tree given a variable the user inputs for how many iterations of the sequence they want to ...
158 views

Foobar Challenge: Lovely Lucky Lambs

I've been able to reduce my solution to constant time. Is it possible to reduce this by any constant factor further? (Besides trivialities i.e. inserting constants, not lazy importing). Specifically, ...
82 views

Time(n) Complexity of Fibonacci Algorithms

It is my first use of classes in Python. I wanted to create something useful and try some new things as I learn this cool language: strategy pattern, testing with nanoseconds precision, curve/poly ...
64 views

Calculate huge Fibonacci Numbers in C++ using GMP and boost::multiprecision

Problem Statement Calculate the exact value of the n-th Fibonacci number, say the one-billionth. Algorithm The algorithm is based on the idea that Fibonacci numbers can be represented as 2x2 ...
91 views

Write in file the n-th term in iccanobiF series

Siruri2 | www.pbinfo.ro Fibonacci, a famous Italian mathematician in the Mediaeval Era, had discovered a series of natural numbers with multiple applications, a string that bears his name: <...
143 views

Fibonacci Nth term using tail recursion [closed]

I have created a program that prints the Nth term of the Fibonacci sequence. The fib function needs to use tail recursion. If what I have coded isn't tail recursion, I would like to know how to change ...
413 views

Recursive Fibonacci in Rust with memoization

I'm trying to come up with an "elegant" way of calculating Fibonacci for number in Rust, using recursion and memoization (self-imposed requirements). This is what I have so far: ...
445 views

Javascript Fibonacci with dynamic programming

Trying to applying what seen on What Is Dynamic Programming and How To Use It (here: https://www.youtube.com/watch?v=vYquumk4nWw ) Obviuously this is the final code, after removing the recursion. I ...
60 views

Output string length and classical Fibonacci sequence in a web page

I wrote a JavaScript and XHTML webpage. I think the format of the output is not better or the validation process is not as it is supposed to be. How can I improve the code? How can I make it more ...
1k views

alternating Fibonacci and prime series

The task is to print the following series 1 2 1 3 2 5 3 7... The elements at odd positions are Fibonacci series terms and the elements at even positions are ...
164 views

Project Euler #2 with a fibSequence and result

I have a background in Linguistics and my journey as an aspiring developer has just begun. I was hoping you could give me a feedback on the solution I have come up with for the second challenge of ...
109 views

Display Fibonacci numbers

I just started coding programs with python. As a challenge I wanted to program something to print out the Fibonacci Numbers. It looks like I've done what I wanted to do (I checked the first few ...
2k views

Performance of dynamic Fibonacci generator and dead rabbits

I would like to improve my code style and its efficiency. I'm just moving beyond the standard recursive approach to a lot of simple algorithms. This post has two code snippets with slightly ...
248 views

I'm just starting to look into Haskell. I've written a naive Fibonacci implementation, and I've also written a more advanced one that uses tail-call recursion for efficiency. ...
475 views

Dynamic Fibonacci algorithm in x86 (MASM)

My task was to implement this algorithm that uses memoization to calculate fibonnaci numbers: ...
292 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 ...
464 views

Huge Fibonacci modulo m optimization in Python 3

I'm doing some an Algorithm Design online course as a way of learning algorithms and Python as well. One of these challenges requires that I write code for finding a "Huge Fibonacci Number Modulo m". ...
454 views

9 ways to generate Fibonacci numbers in C++

This is C++ code that consists of 9 different functions that generate Fibonacci numbers. Although all functions display same result, the emphasis is on practice to use different methods or ways. I ...
882 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 ...
2k views

Table of Tribonacci sequence using NumPy and PANDAS

What I am trying to accomplish is calculate the Tribonacci numbers and the ratio. I can do this in Excel easy like this. So I tried do the same using Python 3 now. It works and gives such output. ...
260 views

Python3 Terminal Based 'Combat' System

This is my first leap into Python and I had a lot of fun writing this - it is not complete yet. I'm interested in adding a perk system next, instead of generically increasing stats I'd like the ...
263 views

Name scope for memoization Fibonacci [closed]

Here's a snippet of code I use to examine the functionality of Python decorator(@memorize). An example of Fibonacci computation: ...
1k views

Fibonacci in linear time by using an extra pointer

I have a function to find the nth number in a Fibonacci sequence, in which I am recursively calling the function. The sum is stored in a class variable and I have an extra pointer I increment every ...
3k views

Python 3 - Fibonacci Implementation

I wrote a function returning the n-th Fibonacci number in Python 3: ...
129 views

Calculating the sum, of the mod Q, position multiplied, sort sequence, of Fibonacci numbers [closed]

I need to write a program that uses the Fibonacci Sequence to calculate a sum. The calculation requirement ...
2k views

Second project Euler solution

The things I'm interested the most from the review are: The performance of the code Overall review of the code structure, styling rules and naming conventions. Problem: 2 By considering the terms ...
276 views

Memoizing in PostScript

The pusherr and poperr procedures maintain an internal stack as a lisp-like linked-list. It's a little slower than an earlier ...
469 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 ...
271 views

Finding the nth Fibonacci number using recursive technique

EDIT So I've been working on this according to the challenge @PeterTaylor gave me. I'm not very good at math, so I've been doing a lot of reading and found this link on the Binet form. Fibonacci ...
788 views

Find the next Fibonacci number [closed]

This code calculates, from a list of integers, the next fibonacci number for each integer. It does this for the first 60 numbers in the sequence. Any pointers on improving computing time, code ...
1k views

Lovely Lucky LAMBs

I am trying to solve this question from google's foobar. However, my code exceeds the time limit, even though when I tested it I got correct answers. How can I make my code more efficient? Lovely ...
135 views

Fizzbuzz some Fibonacci numbers

I was teaching some new people in office a bit of COBOL, so I threw together this exercise where they had to write a program that would generate the first 10 numbers of a Fibonacci suite and then test ...
424 views

A program to find out the number of odd and even Fibonacci numbers between given range

I built a program in C that can tell how many odd and even Fibonacci numbers there are between a given range. Input Specification First line of the input contains ...
816 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. ...
742 views

Finding the n th term in Fibonacci series

Solving a problem in coding contest I came across a problem, which on digging a bit lead me to the data set in this question . Since the program to enumerate and finding the solution was too complex ...
2k views

Finding large Fibonacci Number in Python

I'm doing Project Euler at 1000-digit Fibonacci number - Problem 25 which says The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. ...
153 views

Fibonacci series - a different way

I am a C++ student (1.5 months into it). Please give feedback to this different way I have thought of for Fibonacci series. If there are any improvements needed, please suggest them also. ...
1k 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: ...
352 views

BF welcomes Fibonnaci

Slightly inspired by a previous question/april fools joke I decided to take on Fibonnaci sequence in the lovely language Brainfuck. In order to do this I have also worked on Brainduck, which is a ...
145 views

Better Fibonacci sequence calculation

I attempted to make better Fibonacci sequence calculation algorithm in C++. This was the best I could: ...
1k views

Find fibonacci series upto a given maximum in javascript

I'm attempting to find a fibonacci series where the last number is no greater than a given maximum. Given the start digits 1, 2 ...
175 views

Project Euler problem 2 in Haskell

I have just started Haskell, and I want to check if my code is following the spirit of the language. By considering the terms in the Fibonacci sequence whose values do not exceed four million, find ...
4k views

Project Euler problems 1 and 2 in python

What do you think about my code? I am a beginner and just started doing some algorithmic exercises to sharpen up my python skills. Here is code for problem #1: ...
74 views

Sequence to extend and forget

After receiving some feetback about my previous attempt to create reusable, easily extendable sequence generators I try once again to create such a framework. This time there is no inheritance. Just ...
108 views

Sequence generators not only for potatoes but also for apples and oranges

The last question about sequence generators Growing potatoes in delayed sequences was only about potatoes. I thougt why not make it work with apples and oranges too so I made it generic. The base ...