Tagged Questions

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
52 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 ...
7
votes
3answers
117 views
2
votes
1answer
307 views

O(n) Fibonacci?

I attempted to write an \$O(N)\$ Fibonacci. ...
5
votes
1answer
131 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 ...
8
votes
1answer
101 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 ...
4
votes
1answer
53 views

Zeckendorf numbers the Clojure way

I'm just getting into Clojure, and I wanted to make sure I am writing code the "Clojure way". The challenge I took on is Zeckendorf numbers (fairly trivial). ...
11
votes
4answers
708 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 ...
8
votes
5answers
534 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 ...
8
votes
1answer
366 views

Project Euler #2

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, ...
4
votes
1answer
62 views

Comparison of Fibonacci (Multinacci) Functions in Python3

After coming up with a formula on this Stack Overflow question, defeating recursion limits and finding a few new ways of calculating these numbers (as per this Stack Overflow question), I decided that ...
11
votes
5answers
1k 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. ...
6
votes
1answer
183 views

Memoized Fibonacci

I went ahead and implemented a method to calculate Fibonacci numbers using memoization. ...
12
votes
4answers
230 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 ...
4
votes
0answers
90 views

Fibonacci number function: convert to tail-recursion?

I've been implementing a function for calculating the nth Fibonacci number in F#. So far the best implementation I could come up with is this: ...
21
votes
4answers
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 ...
11
votes
3answers
773 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 ...
23
votes
4answers
3k 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 ...
3
votes
3answers
107 views

How would you count in the Fibonacci Sequence?

I was wondering if I did this in a remotely acceptable way: ...
5
votes
2answers
347 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. ...
6
votes
4answers
615 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 ...
5
votes
1answer
96 views

Four algorithms to find the Nth Fibonacci number

I'm implementing some basic algorithms in Go as an introductory exercise. Here are four different algorithms to find the Nth Fibonacci number. I'm looking for general feedback, but I'm specially ...
6
votes
2answers
173 views
10
votes
3answers
470 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? ...
5
votes
2answers
222 views

Print routes on the stairway when only 1 or 2 steps are possible

Given a staircase with N steps, you can go up with 1 or 2 steps each time. Output all possible ways you go from bottom to top. I'm looking for code review, best practices, optimizations etc. ...
3
votes
2answers
437 views

Fibonacci series, topdown and bottom up approaches, stairway climbing

I have solved fibonacci series and then used the topdown and bottom up approaches to solve it. Also I have included the stairway climbing question as follows "You are climbing a stair case. Each time ...
0
votes
1answer
120 views

Time Limit Exceed Problem [closed]

When I submitted below code in codepad.org, it shows "Time limit exceed" problem. Please provide alternative solution : Problem Statement : Given a number K, find the smallest Fibonacci number that ...
5
votes
2answers
241 views

Is this Fibonacci function right?

Is this a correct method of Fibonacci with recursion? ...
4
votes
2answers
322 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 ...
11
votes
4answers
1k 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 ...
7
votes
3answers
3k 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, ...
6
votes
1answer
111 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 ...
1
vote
1answer
207 views

Better way of calculating Project Euler #2 (Fibonacci sequence)

Even Fibonacci numbers Problem 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, ...
2
votes
3answers
179 views

Maintaining the Single Responsibility Principle with Project Euler #2

This is my solution to Project Euler problem 2: By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. The class ...
3
votes
2answers
179 views

Fibonacci using cache

This is my simple Fibonacci implementation in CoffeeScript. What do you think? Using cache (fibResults), it's very very fast. ...
2
votes
2answers
290 views
2
votes
1answer
1k 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 ...
2
votes
2answers
2k views

Fibonacci sequence implementation

This was too slow for my computer: ...
2
votes
3answers
681 views

Project Euler - Shortening Problem 2

You might have read my question on shortening my code to a one-liner for Problem 1. So, I was wondering, is there any more tricks of the trade to shorten my Problem 2 solution: ...
4
votes
3answers
422 views

Making this reduce() Fibonacci generator better

I've recently discovered how cool reduce() could be and I want to do this: ...
3
votes
1answer
193 views

Euler 2 : Simple Fibonacci

I'm just starting to experiment with F# (from a C# background). I think I'm starting to get into the right way of thinking, but this code still seems pretty awkward. Is there a better (more terse) ...
2
votes
1answer
1k views

Fibonacci heap implementation

I'd like this reviewed. ...
6
votes
4answers
4k 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 ...
5
votes
1answer
362 views

Project Euler question 2 in CoffeeScript

By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. ...
2
votes
2answers
333 views

Is there a better solution to this Fibonacci implementation in Go?

At the end of the Day 1 Go Course slides (pdf) there is an exercise stated as follows (NOTE: the course in the linked presentation is considered obsolete. If you are looking to learn Go the suggested ...
4
votes
2answers
348 views

Producing full list of Fibonacci numbers which fit in an Int

I am progressing through the problems listed at projecteuler.com as I learn Scala (my blog where I am covering this experience). I have written a function to produce all the Fibonacci numbers possible ...
16
votes
3answers
1k 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. ...