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.

learn more… | top users | synonyms

2
votes
2answers
82 views

Fibonacci sequence methods

Decided to get a little JDK 8 practice in today, so I built two methods to print out the golden ratio, one uses the Stream API the other does not. Wanted to request general feedback on how well I ...
6
votes
2answers
67 views

Implement a generic Fibonacci sequence in Rust without using Copy trait

I'm trying to learn Rust and am a beginner. How does one go about implementing a generic version of the Fibonacci sequence without using Copy trait in Rust? My code ...
13
votes
3answers
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 ...
3
votes
0answers
62 views

Over-engineered fizzbuzz

I've got this fizzbuzz project I am using for a blog series, among other things. In this version, the fizzbuzz function is fed from a Fibonacci generator. I'm particularly concerned with the ...
4
votes
3answers
94 views

Wascally Wabbits

This question is part of a series solving the Rosalind challenges. For the previous question in this series, see Mendelian inheritance. The repository with all my up-to-date solutions so far can be ...
3
votes
1answer
321 views

Fibonacci Sequence in BrainF***

I have been trying to write a BrainF*** program that prints the Fibonacci sequence numbers repeatedly. I was wondering whether this is the most efficient way to do it. I basically repeatedly duplicate ...
3
votes
1answer
105 views

My C code for Fibonacci Sequence

I've been learning more programming in the past few years (C, Java, Arduino) for my hobbies. I read the "C for Dummies" book and found that it was good, but did not cover much - especially pointers... ...
1
vote
1answer
65 views

Select the element out of the array if its index is a Fibonacci number [closed]

I've some questions for an exam and wondered if somebody could take a look at my Fibonacci sequence that is supposed to answer this question: "select the element out of the array if its index is a ...
6
votes
2answers
71 views

N-Bonnaci sequence calculator

The code calculates a n-bonnaci sequence to a certain number, based on the user's input. It then can print it to a file and/or print it to the console. The ...
3
votes
1answer
75 views

Fibonacci using OOP methods in Java

I made a simple program that uses OOP methods. Please tell me if I used the 4 methods right. And if not, please show me how. ...
6
votes
1answer
109 views

Project Euler Q2 - Sum of even Fibonacci numbers

I'm very new at F#, and am using Project Euler to help me learn. Question #2 kept me going for a while, as my initial attempt at an answer was very slow and inelegant. Then I learnt about Seq.unfold, ...
11
votes
2answers
116 views

Dynamic Programming: Fibonacci-like recurrence relation

This is a problem from my Introduction to Algorithms textbook. Consider the infinite sequence of numbers An|n>0 = (1,1,3,4,8,11,...) defined recursively as follows. $$ A_n = \left\{\begin{aligned} ...
8
votes
1answer
99 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 ...
11
votes
1answer
199 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. <...
17
votes
2answers
613 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 ...
0
votes
1answer
55 views

Fibonacci sequence and quadratic equation using functions [closed]

I know this code works, but is it correct to define them as functions or should I use something else? ...
6
votes
2answers
82 views

Data-structure exploration

On my quest to learn Ruby I figured exploring the proper usage of different data-structures would be invaluable, including strings, arrays and hashes. I decided to build a hash containing the numbers ...
3
votes
2answers
225 views

Project Euler 25 - x-digit Fibonacci Number

I have solved the Problem 25 of the Euler Project: The Fibonacci sequence is defined by the recurrence relation: \$\qquad F_n = F_{n−1} + F_{n−2}\$, where \$F_1 = 1\$ and \$F_2 = 1\$. ...
12
votes
5answers
2k 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 ...
4
votes
5answers
248 views

Calculating Fibonacci numbers

The following problem is currently taking more than 8 seconds to execute. Please help me to modify the program, so that execution time will be reduced. ...
1
vote
0answers
32 views

Computing even huger Fibonacci numbers in Java - follow-up

See the previous and initial iteration. I have incorporated almost all the suggestions by Peter Taylor: The actual method returns a BigInteger instead of ...
2
votes
2answers
102 views

Computing even huger Fibonacci numbers in Java

See the next iteration. I have that method for computing Fibonacci numbers \$F_n\$ (\$n = 0, 1, 2, \dots)\$, that relies on computing $$ A = \begin{pmatrix} 1 & 1 \\ 1 & 0 \end{pmatrix}^n. $...
4
votes
2answers
792 views

Computing huge Fibonacci numbers in Java

I have this small Java program for computing particurly large Fibonacci numbers (10000th Fibonacci number is computed in about 220 milliseconds). The key idea here is to use lists of digits, which is ...
2
votes
1answer
57 views

Project Euler Problem 2 in Java

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, ... By ...
5
votes
3answers
305 views

Outputting Fibonacci numbers

My program gets some input values and outputs Fibonacci values. Generally, I'm adding single numbers from the right to left, and I'm saving it in the sum value and get rest of it and add to string. (...
5
votes
1answer
884 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 ...
6
votes
2answers
156 views

Rob Pike's Golang presentation excercise of day 1

I'm following this presentation. At the very end there's an exercise about solving Fibonacci and says that instead of addition, make the operation setteable by a function. Is the following is a good ...
5
votes
2answers
293 views

Calculate the Fibonacci sequence using bash

I would like your opinion on my shell script that prints the Fibonacci sequence. ...
0
votes
1answer
85 views

Fibonacci Sequence - Faster method?

Just decided to make a quickie Fibonacci Sequence via jQuery and I was wondering if anybody can think of a faster way to interpret it? I can type pretty much any number in and it returns in a fraction ...
8
votes
4answers
628 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,...
5
votes
1answer
169 views

Recursive Fibonacci generator

I decided to write a function that would generate an index of the Fibonacci sequence making use of Python's mutable default parameter. It's inspired by a question I answered on Stack Overflow where ...
11
votes
1answer
121 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 ...
1
vote
1answer
215 views

SPOJ - POWFIB (Fibo and non fibo) Time Limit Exceeds

Problem Find (a^b)%M, where a = Nth non-fibonacci number b = Nth fibonacci number modulo M M = 1000000007 Consider fibonacci series 1,1,2,3,..... INPUT First line ...
7
votes
1answer
146 views

Implement Fibonacci with `iterate`

I implemented the Fibonacci sequence using iterate. ...
2
votes
3answers
1k views

Fibonacci sum with memoization

Problem: Using the recursion approach, find a Fibonacci sum without repetition of computation. ...
5
votes
4answers
346 views

Two Fibonacci functions

These are two of tasks, which I had to do for the recruitment process to be started in some company. Unfortunately they didn't like it so I've decided to share it here for discussion. Add up all the ...
2
votes
1answer
80 views

Avoid branching code for degenerate cases in Fibonacci generator

I was writing a simple function that would return the Fibonacci sequence up to the nth term and for whatever reason started wasting a lot of time on it. Here's what I came up with: ...
3
votes
1answer
94 views

Testing Fibonacci conjecture

The sequence of Fibonacci numbers is defined as F1 = 1, Fn = Fn−2 + Fn−1. It has been conjectured that for any Fibonacci number F, F2 + 41 is composite. ... [T]ask is to either prove the ...
2
votes
1answer
88 views

Project Euler #2: sum of even Fibonacci numbers, using generators

I am currently working on Project Euler problem #2 which requires you to print the sum of all even fibonacci numbers below 4 million. I just recently learned about generators and from my ...
2
votes
1answer
272 views

Finding the nth element of generalized Fibonacci sequences

I solved the Fibonacci Golf problem on checkio.org: The Fibonacci numbers or Fibonacci sequence are the numbers in the following integer sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21... This is not ...
1
vote
2answers
81 views

Sequence generation problem - Fibonacci

Below is the representation and user interface fib_sequence for generating a Fibonacci sequence: ...
4
votes
2answers
149 views

Sequence processing problems

Problem 1: Sum the even numbers for the first n fibonacci numbers Solution: ...
2
votes
1answer
390 views

Memoization of Fibonacci using generic Int => Int helper

I'm trying to understand memoization using Scala. I took the Fibonacci sequence as an example because of the high cost of recursively computing numbers in the sequence without memoization. ...
2
votes
1answer
1k views

Project Euler 25 - 1000-digit Fibonacci Number

I have recently completed problem 25 from the project Euler site. The Fibonacci sequence is defined by the recurrence relation: \$\qquad F_n = F_{n−1} + F_{n−2}\$, where \$F_1 = 1\$ and \$F_2 ...
52
votes
2answers
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? ...
2
votes
2answers
314 views

Tail Recursive Fibonacci

Please critique my implementation of a tail-recursive method for generating the Fibonacci sequence: ...
8
votes
3answers
1k 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 ...
5
votes
0answers
161 views

Evaluating Fibonacci-sequence-based recurrence relation (SPOJ Flibonakki)

I have a function fib2 which returning two values as Tuple but I want to print the product of tuples returned by function fib2. I am new to Haskell so please ...
12
votes
3answers
667 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 ...
11
votes
8answers
929 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/), ...