The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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.

163 questions
Filter by
Sorted by
Tagged with
4k views

I HAZ A FIBO, RLY

First LOLCODE program, run here. This program inputs a Fibonacci number from the user, then determines and prints whether the number is in the Fibonacci series. What do you think? ...
5k views

Everyone loves Fibonacci

I was bored and burnt out on more serious projects.... until I saw this Computerphile video on YouTube. Now I'm inspired again. Now I feel like spending some time implementing that recursive algorithm ...
1k views

Standardly deviated Fibonacci

I'm new to C++ (about 4 weeks with no prior programming experience in other languages) and am writing a program that's supposed to do the following: Define an array of 100 sequential numbers of type <...
658 views

Telling fibonaccis to the user

Though this program tells the truth (unless you change the source code), it does tell Fibonacci numbers, depending on the user's input. Keeping in mind of all (or most) of the feedback given from ...
2k views

Project Euler Problem 2 in Clojure

I am in the process of learning Clojure. I am fairly new to functional programming and would like to know if my code smells or if there are any performance implications with my approach. ...
3k views

Project Euler #2 (Even Fibonacci numbers) in Swift

I figured working through Project Euler problems in Swift would be a good way to learn any tips or tricks. For example, tuples are something I'm not used to using, but they proved useful here. Using ...
3k 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 ...
388 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 ...
1k views

Using Fibonacci sequence to generate musical melodies

I recently started picking up the Haskell programming language. I've managed to learn other languages rather quickly, but I'm still having a difficult time grasping some of the basics of Haskell. I ...
4k views

Fibonacci sequence in C

I'm very new to C, so pointing out better ways of doing things, errors, bad practices, etc would be optimal at this stage. Code on GitHub ...
4k 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 ...
3k views

Python 3 - Fibonacci Implementation

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

Dynamic programming with Fibonacci

I have written the following code using a dynamic programming technique. Can I use ArrayList here? Please let me know if I can improve this code. ...
1k views

Does everyone still love Fibonacci?

I'm following up on this question. I made a few decisions about my model and implemented recommendations accordingly. TL;DR the link Uses a loop algorithm to return a Fibonacci number $Fn$ of ...
1k views

Calculating Fibonacci sequence in several different ways

I'm doing an experiment trying to freshen up my unit-testing and learn dynamic programming. Every test passes but I'm curious of the result of some of them and worried if I'm doing the testing ...
1k views

Lock-free thread-safe Fibonacci number generator

Here is my implementation of a lock-free thread-safe Fibonacci number generator. Is it correct? The idea is to use an immutable holder for previous and current numbers (since it's hard to change two ...
789 views

Project Euler #2 Even Fibonacci numbers

Problem: 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, ... ...
600 views

Dynamic Programming: Fibonacci-like recurrence relation

This is a problem from my Introduction to Algorithms textbook. Consider the inﬁnite sequence of numbers An|n>0 = (1,1,3,4,8,11,...) deﬁned recursively as follows.  A_n = \left\{\begin{aligned} &...
435 views

I'm not sure if I still love Fibonacci, but my code is getting better. How much better?

Technically, this is a follow up to these two questions, but I have taken a radically different approach. Everybody Loves Fibonacci Does everyone still love Fibonacci I finally allowed myself to be ...
235 views

The dwindling Fibonacci

I've recently taken a renewed interest in non-standard languages like Brainfuck and TIS-100. I'm currently writing a Fibonacci generator in Brainfuck which differs a bit in approach from the usual ...
1k views

Fibonacci checker

I wrote a simple Fibonacci checker using HTML, CSS, and JS. This is my first JS program, so be sure to tell me everything that is wrong with it. Check it out here (http://jsfiddle.net/z49fyypt/1/), ...
22k views

Python Solution for Project Euler #2 (Fibonacci Sums)

I'm a fairly new programmer (just started yesterday!). I decided to tackle Project Euler #2 today, as I did #1 yesterday without many problems. I came up with what seems to me to be a working solution,...
436 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. <...
11k views

Recursive Memoized Fibonacci in C++

I was reading an article on Wikipedia about memoization, so I wanted to try and apply it. I am fairly new to this subject, so I thought I'd start small. Does the program use memoization correctly? Is ...
3k 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 ...
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. ...
16k views

Project Euler Question #2: Sum of even Fibonacci numbers under 4 million

The question is: 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, ...
2k 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 ...
1k views

Recursive Fibonacci with Generic delegates

Here is a fast recursive Fibonacci-like for loop. How can it be more readable, and is it possible remove TArgs? ...
277 views

Project Euler #2 - Sum of even Fibonacci numbers to 4,000,000

This particular problem has already been posted here before, but the community is ok with me to post it again, so I can have feedback on my own implementation. I tried to keep things simple, with ...
5k views

Fibonacci generator with Golang

This is my Fibonacci generator: package main import "fmt" func main() { for i, j := 0, 1; j < 100; i, j = i+j,i { fmt.Println(i) } } It's ...
756 views

Project Euler #2 in Python

Here is my Python code for Project Euler #2: 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, ...
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 ...
2k views

Project Euler #2 (Fibonacci Sequence)

Challenge: 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. Consider a ...
2k views

Another even Fibonacci numbers implementation

This is intended as something of a comparative study. I'm including not just one, but two separate implementations of code to implement the Project Euler problem to sum the even Fibonacci numbers up ...
7k views

Program for finding Fibonacci primes

I think it could have been designed with more object orientation. I don't like how one of my methods calls another from within the method, but I wasn't sure how to return the result because it is a ...
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 ...
164 views

Optimize RecursionArray interface

I created a class a while ago that I named a "Recursion Array". It is a way to create dynamically memoized sequences such as the Fibonacci sequence or the factorial numbers sequences. The concept is ...
965 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 ...
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 ...
2k views

Yet another Fibonacci number generator

First attempt at dynamic programming. I want to make this run faster and better. fibonacci.cpp ...
14k views

Fibonacci sum with memoization

Problem: Using the recursion approach, find a Fibonacci sum without repetition of computation. ...
169 views

Calculating Fibonnaci sequence lazily

Implementation: ...
8k views

Calculate fibonacci in O(log n)

This program calculates the $n$th fibonacci number, in $O(\log n)$ time. I'm looking for code review, optimizations, and best practices. ...
750 views

Terminating a C loop when maximum hardware limit reached

In response to the SO question C: f>0 vs Perl: \$f>0?, the use of overflow to terminate the loop is referred to as "poor programming practice". Paraphrased: Your c code is actually exiting because ...
2k 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 ...
2k views

More efficient solution for Project Euler #2 (sum of Fibonacci numbers under 4 million)

I would like to get some feedback on my code. I am starting to program after doing a few online Python courses. Would you be able to help me by following my track of thinking and then pinpointing ...
389 views

Implement Fibonacci with iterate

I implemented the Fibonacci sequence using iterate. ...