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

3
votes
1answer
75 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
52 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
68 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
63 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
98 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
108 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
96 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
191 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. ...
16
votes
2answers
609 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
51 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
77 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
203 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
1k 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
182 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
31 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
101 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
768 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
47 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
304 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
414 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
135 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
225 views

Calculate the Fibonacci sequence using bash

I would like your opinion on my shell script that prints the Fibonacci sequence. ...
0
votes
1answer
72 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
622 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: ...
5
votes
1answer
158 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
113 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
195 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
137 views

Implement Fibonacci with `iterate`

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

Fibonacci sum with memoization

Problem: Using the recursion approach, find a Fibonacci sum without repetition of computation. ...
5
votes
4answers
316 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
78 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
92 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
84 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
255 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
80 views

Sequence generation problem - Fibonacci

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

Sequence processing problems

Problem 1: Sum the even numbers for the first n fibonacci numbers Solution: ...
2
votes
1answer
293 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 ...
47
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
248 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
148 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
630 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
926 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/), ...
4
votes
1answer
498 views

Clojure Fibonacci

I'm a Clojure novice working through 4Clojure problems. In one problem I am supposed to create a function that takes a number and returns that number of Fibonaccis. My first thought was to create a ...
2
votes
2answers
108 views

Project Euler #2 in F#

Project Euler Problem 2 asks for the sum of all even Fibonacci numbers below 4 million. My first attempt at this problem using functional programming with F#. I would've liked to use some kind of ...
6
votes
2answers
1k views

Project Euler #2 Efficiency

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: ...
7
votes
4answers
150 views

Calculating Fibonnaci sequence lazily

Implementation: ...
2
votes
1answer
341 views

O(n) Fibonacci?

I attempted to write an \$O(N)\$ Fibonacci. ...
5
votes
1answer
453 views

Iterative Fibonacci sequence using standard library functions

We're all aware of Fibonacci sequence calculators but they look like C-style code. I want to avoid that and take advantage of the standard library. This code is very short, so I'm focusing on ...