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.
8
votes
3answers
554 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
...
1
vote
1answer
76 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 ...
4
votes
2answers
119 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:
...
1
vote
1answer
67 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 ...
4
votes
2answers
90 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 ...
1
vote
1answer
105 views
Growing potatoes in delayed sequences
In order to grow potatoes I'm implementing the retry pattern. If I fail to grow them, I'd like to try it again later. The first part I've implemented is a collection of delay generators.
Their base ...
2
votes
1answer
88 views
Generating Fibonacci sequences in Scala
Would you consider this to be idiomatic Scala? If not, what would you do to improve it?
...
3
votes
2answers
213 views
Benchmarking inline vs normal functions in C++
I am currently learning C++ and have learnt about inline functions and how they can give a performance benefit.
How could this be improved?
...
3
votes
2answers
44 views
Zeckendorf Representation of positive integer
Zeckendorf's theorem states that all positive integers crepresented uniquely as the sum of one or more distinct Fibonacci numbers in such a way that the sum does not include any two consecutive ...
3
votes
2answers
74 views
Stack based non-recursive Fibonacci - Go implementation
The following function computes a the last element in a Fibonacci sequence in Go language.
...
3
votes
1answer
101 views
Modified Fibonacci method implementation - dynamic programming
I found this question on Hackerrank in dynamic programming:
Define a modified Fibonacci sequence as:
$$t_{n+2} = t_n + t_{n+1}^2$$
Given three integers, \$t_1\$, \$t_2\$, and \$n\$, compute ...
3
votes
3answers
211 views
Lucas sequence implementation
Could you suggest any improvements in this Lucas sequence's implementation:
...
5
votes
4answers
134 views
Sum of even Fibonacci numbers
So, in my first attempt I created a code that generated all fibonacci numbers and appended to a list. This list I then traversed to get the even numbers and added them up. It worked, but took like 5 ...
7
votes
6answers
1k views
Yet another Fibonacci number generator
First attempt at dynamic programming. I want to make this run faster and better.
fibonacci.cpp
...
1
vote
1answer
78 views
Nth Fibonacci number (Bottom-up with dict)
This is an algorithm that I wrote to get the nth Fibonacci number using bottom-up dictionary. How can I make this better/more efficient?
...
3
votes
1answer
64 views
Iterative Fibonacci sequence
I implemented a function that prints all the numbers from the Fibonacci sequence until max_num. The minimum value allowed is 0 (so, fib(0) prints 1). It works until ...
2
votes
2answers
111 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
159 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
86 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
133 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
442 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
220 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
84 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
80 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
134 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
121 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
128 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
208 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
234 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.
<...
18
votes
2answers
619 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
63 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
86 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
282 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 ...
5
votes
5answers
710 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
115 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
982 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
94 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
320 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. (...
6
votes
1answer
3k 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
193 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
652 views
Calculate the Fibonacci sequence using bash
I would like your opinion on my shell script that prints the Fibonacci sequence.
...
0
votes
1answer
143 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
644 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
237 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 ...
12
votes
1answer
153 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
249 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
167 views