Questions tagged [fibonacci]

The challenge involves Fibonacci numbers or one of their generalizations.

Filter by
Sorted by
Tagged with
15
votes
11answers
1k views

Phibonacci - Relation between Phi and Fibonacci

You want to see how quickly the ratio of two consecutive Fibonacci numbers converges on φ. Phi, known by the nickname "the golden ratio" and written as \$φ\$, is an irrational number, almost ...
23
votes
4answers
549 views

The half-step of Fibonacci

Challenge Implement the 1-indexed sequence A054049, which starts like this: ...
12
votes
11answers
1k views

Variable length Fibonacci word

Challenge For any two non-empty strings A and B, we define the following sequence : F(0) = A F(1) = B F(n) = F(n-1) + F(n-2) Where ...
19
votes
15answers
3k views

Complex Fibonacci numbers

The Binet formula is a closed form expression for the \$n\$'th Fibonacci number: $$F_n = \frac {\phi^n - (1-\phi)^n} {\sqrt 5}$$ where \$\phi = \frac {1 + \sqrt 5} 2\$ is the golden ratio. This ...
17
votes
19answers
2k views

Fibonacci Encoding

Fibonacci coding is a universal code, which can encode positive integers of any size in an unambiguous stream of bits. To encode an integer \$ n \$: Find the largest Fibonacci number less than or ...
19
votes
17answers
2k views

Fibonacci trees

Background Fibonacci trees \$T_n\$ are a sequence of rooted binary trees of height \$n-1\$. They are defined as follows: \$T_0\$ has no nodes. \$T_1\$ has a single node (the root). The root node of \$...
24
votes
18answers
2k views

Pascal's Fibonacci Triangle

What do you get when you cross Pascal's Triangle and the Fibonacci sequence? Well, that's what you have to find out! Task Create a triangle that looks like this: ...
18
votes
19answers
2k views

The Fibonacci Rectangular Prism Sequence

What is the Fibonacci Rectangular Prism Sequence? The Fibonacci Rectangular Prism Sequence is a sequence derived from the Fibonacci sequence starting with one. The first 3 numbers of the Fibonacci ...
29
votes
25answers
3k views

Implement the random Fibonacci sequence

The random Fibonacci sequence is defined as follows: $$ f_n = \begin{cases} f_{n-1}+f_{n-2} \text{ with probability } 1/2 \\ f_{n-1}-f_{n-2} \text{ with probability } 1/2 \\ \end{cases} $$ $$ f_1 = ...
22
votes
19answers
2k views

Smallest Fibonacci Multiples

Sandbox Background (not necessary for the challenge) A standard number theory result using the pigeonhole principle is the fact that given any natural number k, there is a Fibonacci number that is a ...
1
vote
0answers
77 views

Making Fibonacci Cry [duplicate]

Introduction The Fibonacci sequence is a mathematical sequence in which each term is the sum of the \$2\$ terms before it; the first two terms are \$0\$ and \$1\$. The first few terms are \$0, 1, 1, ...
20
votes
12answers
2k views

Indexing the Extended Fibonacci Numbers

You've probably heard of Fibonacci numbers. Ya know, that integer sequence that starts with 1, 1, and then each new number is the sum of the last two? ...
5
votes
5answers
175 views

Fibonacci with n numbers instead of 2 [duplicate]

How to Given an integer n start with n ones (i.e. 4 -> 1 1 1 1). Then sum up the last ...
9
votes
5answers
215 views

Find the minimal initial values [duplicate]

Consider a sequence F of positive integers where F(n) = F(n-1) + F(n-2) for n >= 2. The ...
23
votes
12answers
6k views

Is this number secretly Fibonacci?

Background Most of you know what a Fibonacci number is. Some of you may know that all positive integers can be represented as a sum of one or more distinct Fibonacci numbers, according to Zeckendorf'...
19
votes
25answers
3k views

Converting a number from Zeckendorf Representation to Decimal

About Zeckendorf Representations/Base Fibonacci Numbers This is a number system which uses Fibonacci numbers as its base. The numbers consist of 0 and 1's and each 1 means that the number contains ...
8
votes
0answers
147 views

Find a way to determine to which fibonacci squares a given coordinate belongs [closed]

Given a random coordinate (x,y), determine in which square (squares are referenced by their sidelength) it is (or the borders of which squares). The squares are drawn in a counter clockwise direction,...
1
vote
10answers
1k views

Indent your code according to Fibonacci

Okay, so I saw this in a meme and decided it'd be the perfect code golf challenge: I prefer to increase the side of my indents according to the Fibonacci sequence: ...
14
votes
10answers
728 views

Sequentia Filii Bonacci

Leonardo of Pisa (ca. 1175 - ca. 1245) is better known as Fibonacci. But this is actually a short for the Latin "filius Bonacci" (the son of Bonacci) which was made up during the 18th century (...
16
votes
12answers
2k views

Find the Fibonacci Patterns

You are probably familiar with the Fibonacci sequence where the first two terms are 0, 1 (or sometimes 1, 1) and every term ...
32
votes
32answers
4k views

Binary Fibonacci

Challenge You need to generate a program or function that takes in a positive integer N, calculates the first N terms of the Fibonacci sequence in binary, concatenates it into a single binary number, ...
-4
votes
1answer
142 views

Find prime factors of sum of non-composite Fibonacci numbers up to n

The Challenge Given a number, find the sum of the non-composite numbers in the Fibonacci sequence up to that number, and find the prime factors of the sum. For example, if you were given 8, the non-...
20
votes
20answers
4k views

Find the Missing Numbers in the Fibonacci Sequence Mod K

Inspired by this Math.SE question. Background The Fibonacci Sequence (called F) is the sequence, starting 0, 1 such that each ...
22
votes
10answers
2k views

The lowest initial numbers in a Fibonacci-like sequence

Given a positive integer input N, output the two non-negative numbers, a and b, where a < b, with the lowest possible mean value that will result in the number N being part of the recurring ...
13
votes
10answers
589 views

Counting Fibonacci Orbits

If we define a Fibonacci-like sequence as fk(n) = (fk(n-1) + fk(n-2)) % k, for some integer k (where % is the modulo operator), the sequence will necessarily be cyclic, because there are only k2 ...
5
votes
4answers
260 views

Implement the Fibonacci sequence… Shifted to the right [duplicate]

Background We all know the famous Fibonacci sequence, where each term is the sum of the previous two, with the first term being 0 and the second one being ...
20
votes
21answers
1k views

Within Fibonacci Numbers

The Challenge Given an integer input, return the first Fibonacci number that contains the input within itself along with the index of that Fibonacci number (indexes starting at 0 or 1 - up to you, ...
8
votes
14answers
1k views

Reverse Fibonacci

Your task You must write a program, to print a reverse Fibonacci series, given a number. Input A non-negative integer N. Output You must output all the Fibonacci numbers from Fk to F0, where k is the ...
18
votes
3answers
566 views

When Fibonacci meets the Queens

(inspired by Helka's response to my random pairing of "chess" and "Fibonacci" tags in chat) Fibonacci The Fibonacci numbers are one of the more well-known sequences in mathematics, where each number ...
49
votes
13answers
7k views

Extreme Fibonacci

There have been a billion iterations of Fibonacci challenges on this website, so lets spice things up with a Fibonacci challenge of a billion iterations! Your challenge is to output the first 1000 ...
29
votes
33answers
14k views

Find the closest Fibonacci Number

We are all familiar with the famous Fibonacci sequence, that starts with 0 and 1, and each element is the sum of the previous ...
30
votes
36answers
5k views

Fibtraction - Fibonacci but with subtraction [duplicate]

The Fibtraction sequence (as I call it) is similar to the Fibonacci sequence except, instead of adding numbers, you subtract them. The first few numbers of this challenge are: ...
24
votes
13answers
2k views

Divinacci Sequence

Divinacci (OEIS) Perform the Fibonacci sequence but instead of using: f(n) = f(n-1)+f(n-2) Use: ...
11
votes
10answers
1k views

Am I a Special N-bonacci Number?

The N-bonacci sequence, originally invented by @DJMcMayhem in this question, is a sequence generated by starting with the integers 0 and 1, and then adding the previous N numbers to generate the next ...
25
votes
17answers
3k views

Print the nth Fibonacci number containing the nth Fibonacci number!

Challenge You must write a program that takes a positive integer n as input, and outputs the nth Fibonacci number (shortened as ...
50
votes
62answers
10k views

Am I a Fibonacci Number?

Your Task: Write a program or function to check if a number that is inputted is a Fibonacci number. A Fibonacci number is a number contained in the Fibonacci sequence. The Fibonacci Sequence is ...
15
votes
20answers
1k views

Sum my Fibonaccified divisors!

The famous Fibonacci sequence is F(0) = 0; F(1) = 1; F(N+1) = F(N) + F(N-1) (for this challenge we are beginning with 0). Your challenge: Given n, output the sum ...
27
votes
48answers
4k views

Golf a Custom Fibonacci Sequence

The Fibonacci sequence is a fairly well known thing around here. Heck, it even has its own tag. However, for all that, we sure like to stick to our roots of ...
13
votes
13answers
2k views

Implement the Fibonacci-quine

A Quine is a program which outputs its source when run. In this challenge, You should make a Fibonacci-quine, a variant of the quine. What is a Fibonacci-quine? A Fibonacci-quine is a program, ...
20
votes
11answers
939 views

Linear interpolation of the Fibonacci sequence

Your task is to find the nth Fibonacci number, but n is not necessarily an integer. The Fibonacci sequence, 0-indexed, goes as follows: ...
26
votes
42answers
2k views

Answer-Chaining Fibonacci

(Inspired by ASCII's 95 Characters...95 Movie Quotes) The Challenge Given input n, output the nth Fibonacci number. You can ...
14
votes
21answers
2k views

Counter-Fibonacci Sequences

Given three numbers m,n and p, your task is to print a list/array of length p starting with m and n and each element after p represents the difference of the 2 numbers before it, m-n (Counter-...
19
votes
20answers
2k views

Arithmetic mean of prime Fibonacci Numbers up to the x Fibonacci Number

You should have heard about the Fibonacci Numbers, often called the Fibonacci Sequence. In this sequence the first two terms are 0 and 1, and every number after the first two is the sum of the two ...
27
votes
2answers
933 views

Find the Fibonacci Kernel

You've probably heard of the Fibonacci numbers; they're pretty famous. Each number in the Fibonacci sequence is the sum of the last two in the sequence with the first and second numbers being 1. The ...
19
votes
14answers
2k views

Your Base to 1-2-3-Tribonacci to Binary back to Your Base

Background The 1-2-3-Tribonacci Sequence Imagine for a second that you could make a fibonacci sequence by replacing the standard iteration formula with the following: Basically, instead of summing ...
30
votes
26answers
3k views

Digital Sum Fibonacci

We are all familiar with the Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765 However, instead of, <...
24
votes
12answers
2k views

Alternating Power Fibonacci Sequence

Definition The Alternating Power Fibonacci Sequence is formed as follows. Start with the empty sequence and set n to 1. Compute fn, the nth non-negative Fibonacci number, with repetitions. 0 is the ...
14
votes
15answers
2k views

Permanently self-modifying code

Now, we all know most languages have very simple ways to "self-modify" code. However, what if you were to actually modify the code and edit parts of it...on disk? Your goal is to make code that ...
22
votes
31answers
4k views

Sum the First n Even Fibonacci Numbers

There seems not to be a contest for this one yet. The task is simple. Add the first n numbers of the Fibonacci sequence that are even and output the result. This ...
13
votes
24answers
833 views

Fibonacci Exponents

For this challenge, you are to output the result of the sum of some numbers. What are these numbers? Well, you are given input, (a, ...