The 2024 Developer Survey results are live! See the results

# Questions tagged [fibonacci]

The challenge involves Fibonacci numbers or one of their generalizations.

128 questions
Filter by
Sorted by
Tagged with
198 views

### Non-Decreasing Fibonacci Sequence modulo M

Given integers $a,b,m, k, n$ and array $F = (f_1, f_2,...,f_n)$ defined as: \begin{cases} f_1 = \text{a}\\ f_2 = \text{b}\\ f_i = (f_{i-1} + f_{i-2}) \text{ mod m},∀i > 2 \end{cases} When $F$ ...
• 123
1 vote
243 views

### Write a function that takes an input string and encodes it using a modified Fibonacci sequence in reverse [closed]

Given an input string, first convert each character to its ASCII value. Generate a reversed Fibonacci sequence of the same length as the input string. Encode each character by adding its ASCII value ...
• 21
3k views

### Draw a Fibonacci Swoosh

Title courtesy of Greg Martin For this challenge, I'll define an arc of size $k$ as a single piece of a sine wave with a length of $k$ units and an height of $\frac{k}{4}$ units: And I'll ...
• 39.3k
950 views

### Unnecessary Fluff

Following the great advice (what do you mean it's not advice?!) on Adding unnecessary fluff we can devise the following task: Take a list of positive integers and a positive integer $m$ as input. ...
• 10.6k
516 views

### Zeckendorf to F(4k+2) representation

Background Fibonacci numbers are defined as follows: $$F_0 = 0, F_1 = 1, F_n = F_{n-1} + F_{n-2}$$ The Zeckendorf representation is a representation of positive integers as a sum of one or more non-...
• 78k
4k views

### Repeat your program to print Fibonacci numbers

Write a program fragment so that, when repeated N times it prints the Nth Fibonacci number. For example, if your program is print(x) then: ...
• 12.8k
3k views

### Give the fool's Fibonacci sequence

Recently I asked for tips on improving some code-golf of mine. The code was supposed to output every third value of the Fibonacci sequence starting with 2: ...
• 99.3k
1 vote
195 views

### Shorten this recursive even fibonacci implementation [closed]

I have the following Haskell code to generate the the values of the Fibonacci sequence which are even as an infinite list: ...
• 99.3k
1k views

### Fibonacci Binary Squares

I was playing with the Fibonacci sequence in binary like so (note that the binary representations are written here from smallest bit to largest bit): ...
• 1,767
2k views

### Write a number as a sum of Fibonacci numbers

In 2009, Hannah Alpert described the "far-difference" representation, a novel way of representing integers as sums and differences of Fibonacci numbers according to the following rules: ...
• 8,689
3k views

### Fibonacci word fractal

The Fibonacci word is a sequence of binary strings defined as: $F_0 =$ 0 $F_1 =$ 01 $F_n = F_{n-1} F_{n-2}$ The first ...
• 49k
2k views

• 78k
3k 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: ...
• 367
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 ...
• 399
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 = ...
• 50.1k
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 ...
• 2,501
1 vote
84 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, ...
• 2,203
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? ...
• 59.3k
189 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 ...
• 1,528
222 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 ...
• 10.4k
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'...
• 1,650
4k 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 ...
176 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
2k 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: ...
• 11.8k
761 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 (...
• 194k
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 ...
• 9,459
5k 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, ...
• 729
154 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-...
• 111
6k 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 ...
• 3,528
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 ...
• 46.4k