# Questions tagged [sequence]

For challenges involving sequences, typically of numbers following some pattern.

332 questions
Filter by
Sorted by
Tagged with
44k views

### Fibonacci function or sequence

The Fibonacci sequence is a sequence of numbers, where every number in the sequence is the sum of the two numbers preceding it. The first two numbers in the sequence are both 1. Here are the first ...
• 4,937
8k views

### Catalan Numbers

The Catalan numbers (OEIS) are a sequence of natural numbers often appearing in combinatorics. The nth Catalan number is the number of Dyck words (balanced strings of parenthesis or brackets such as <...
• 11.2k
13k views

### Collatz Conjecture (OEIS A006577)

This is the Collatz Conjecture (OEIS A006577): Start with an integer n > 1. Repeat the following steps: If n is even, divide it by 2. If n is odd, multiply it by 3 and add 1. It is proven that ...
• 71.5k
3k views

### Say What You See

The "Look and say" or "Say what you see" sequence is a series of numbers where each describes the last. ...
• 471
3k views

### Josephus problem (counting out)

The challenge Write a function that takes two positive integers $n$ and $k$ as arguments and returns the number of the last person remaining out of $n$ after counting out each $k$-th person. ...
• 23.5k
11k 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 ...
• 7,235
8k views

### Numbers with Rotational Symmetry

Given an integer, output a truthy value if it is the same upside-down (rotated 180°) or a falsy value otherwise. 0, 1, and ...
• 23.4k
3k views

### Different Way Forward

Given a list of integers produce a Forward Difference at a specified order/depth. For the list of integers: (10, 18, -12, 4, 8, -3, -5, 67, 9, 14) The Forward ...
• 12.2k
2k views

### Spell out the Revu'a

Actually not inspired neither by Atbash Self Palindromes nor by Generalized Gematria Calculator. Given a string s of length n, output the Revu'a sequence, which is the first character of s, the first ...
• 30.8k
5k views

### Generate a Kolakoski sequence [duplicate]

Definition1 A Kolakoski sequence is a self-describing infinite sequence {kn} of alternating blocks of 1's and 2's, given by the following rules: k0 = 1 kn = the length of the (n+1)'th ...
• 2,319
5k views

### Generate Monday Numbers

Monday numbers, as defined by Gamow in this question over on Puzzling, are positive integers N with the following three properties: The decimal representation of N does not contain the digit 0 The ...
• 43.5k
10k views

### Look and say sequence [duplicate]

The look and say sequence is a basic form of run length encoding. The sequence starts with the number 1 and each additional number encodes the number of digits that are repeated before each digit ...
• 3,348
1k views

### Return each number from a group of numbers

The challenge The program must return all numbers included into a group (comma and hyphen separated sequence) of numbers. Rules s is the sequence string; all ...
20k views

### One OEIS after another

As of 13/03/2018 16:45 UTC, the winner is answer #345, by Khuldraeseth na'Barya. This means the contest is officially over, but feel free to continue posting answers, just so long as they follow the ...
• 50.1k
7k views

### An abundance of integers!

An Abundant number is any number where the sum of its proper divisors is greater than the original number. For example, the proper divisors of 12 are: ...
• 59.4k
5k views

### Generate the Abacaba sequence

This challenge is about printing the abacaba sequence of a specific depth. Here is a diagram of the first 5 sequences (a(N) is the abacaba sequence of depth N, ...
• 8,152
4k views

### Sums of Consecutive Integers

Before anyone says anything, similar and similar. But this is not a dupe. Some positive integers can be written as the sum of at least two consecutive positive integers. For example, ...
• 7,387
5k views

### Generate Recamán's sequence

Recamán's sequence (A005132) is a mathematical sequence, defined as such: A(0) = 0 A(n) = A(n-1) - n if A(n-1) - n > 0 and is new, else A(n) = A(n-1) + n A ...
• 2,073
4k views

### Flipping pancakes

In pancake sorting the only allowed operation is to reverse the elements of some prefix of the sequence. Or, think of a stack of pancakes: We insert a spatula somewhere in the stack and flip all the ...
• 18.6k
10k views

### List Prime Numbers [duplicate]

Introduction Prime numbers are simple, right? Well, now you get your chance to find out! Challenge You must write a program or function that takes an input n and ...
• 454
930 views

### Counting generalized polyominoes

This challenge will have you count pseudo-polyforms on the snub square tiling. I think that this sequence does not yet exist on the OEIS, so this challenge exists to compute as many terms as possible ...
• 8,689
689 views

### New Order #1: How does this feel?

Introduction Putting all positive numbers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all positive numbers. ...
• 2,941
5k views

### Generate Dennis Numbers

This challenge is a tribute to PPCG user Dennis for winning the robbers' part of The Programming Language Quiz. Looking at Dennis' PPCG profile page we can see some pretty impressive stuff: He ...
• 89.9k
9k views

### Compute the Kolakoski sequence

This is a repost of an old challenge, in order to adjust the I/O requirements to our recent standards. This is done in an effort to allow more languages to participate in a challenge about this ...
• 197k
2k views

### Stackable sequences

You deal cards labeled 0 to 9 from a deck one a time, forming stacks that start at 0 and count up by 1. When you deal a 0, you place it on the table to start a new stack. When you deal any other ...
• 146k
2k views

### Equality in the sum of digits

Introduction Let's take the number 180. This is an interesting number because the sum of digits of this number is equal to: ...
• 44.5k
4k views

### All together now

Given a list of digits 1 through 9, output whether each digit is grouped together as a single contiguous block. In other words, no two of the same digit are separated by different digits. It's OK if a ...
• 146k
3k views

### Monday Mini-Golf #1: Reverse Fibonacci Solver

Monday Mini-Golf: A series of short code-golf challenges, posted (hopefully!) every Monday. A Fibonacci-like sequence is obtained using the same method as the famous Fibonacci sequence; that is, each ...
• 50.1k
5k views

### Hamming numbers

Hamming numbers are numbers which evenly divide a power of 60. Equivalently, their prime factors are all $\le 5$. Given a positive integer, print that many Hamming numbers, in order. Rules: Input ...
• 1,297
999 views

### Generate Programs in Increasing size

In this challenge, you will write a program which outputs a program which is the double the length of the original program. The outputted program should output a new program a program double its ...
• 29k
4k views

### Female and Male Sequences

This question is probably harder than all of those "generate a sequence of numbers" tasks, because this requires TWO sequences working in unison. Really looking forward to the answers! In his book "...
• 6,990
1k views

### Calculate the n-th iterate of a polynomial for a specific value; fⁿ(x)

Given a polynomial function f (e.g. as a list p of real coefficients in ascending or descending order), a non-negative integer n, and a real value x, return:    f n(x) i.e. the value of f (f (f (…f (x)...
• 30.8k
757 views

### Find the missing number in an undelimited string

The challenge is to identify the missing number in a string of undelimited integers. You are given a string of digits (valid input will match the regular expression ...
2k views

### Generate n digits of Gijswijt's sequence

Introduction Gijswijt's sequence (A090822) is famously really, REALLY slow. To illustrate: The first 3 appears in the 9th term (alright). The first 4 appears in the 220th term (a long way away, but ...
• 6,990
2k views

### Partial Sum of Harmonic Sequence!

Definition In Mathematics, Harmonic Sequence refers to a sequence where $$a_n = \frac 1 n$$ i.e. the $n_{th}$ term of the sequence equals the reciprocal of $n$. Introduction In this challenge, ...
• 5,074
1k views

### Three triangular numbers [closed]

Description There have been quite a few other challenges concerning these numbers before, and I hope this one is not among them. The n th triangular number equals the sum of all natural numbers up to ...
• 1,103
1k views

### What comes next?

Given a space-separated list of integers, your task is to find the next integer in the sequence. Each integer in the sequence is the result of applying a single mathematical operation(...
• 11.3k
855 views

### New Order #2: Turn My Way

Introduction (may be ignored) Putting all positive numbers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all ...
• 2,941
574 views

### Pack sequences of non-negative integers

Let N be the set of nonnegative integers, i.e. {0, 1, 2, 3, ...}. Let c0(N) be the set of all infinite sequences in N that converge to 0, i.e. { (xn) ∈ NN | xn → 0 as n → ∞}. c0(N)...
• 8,806
27k views

### 4, 8, 15, 16, 23, 42 [closed]

4, 8, 15, 16, 23, 42 Write a program that outputs this sequence of numbers infinitely. However, The Numbers must not appear in your source code anywhere. The following is not a valid Java program to ...
• 2,416
7k views

### Calculate Phi (not Pi)

No, I don't mean $\phi = 1.618...$ and $π = 3.14159...$. I mean the functions. $\phi(x)$ is the number of integers less than or equal to $x$ that are relatively prime to $x$. $π(x)$ is ...
17k views

### Print numbers from 1 to 10

This might be a very simple challenge, but I am surprised it hasn't been done on code-golf yet: Print all Integers from 1 to 10 inclusive in ascending order to standard output. Your output format ...
• 993
4k views

### Fibonacci-orial

Definition Fibonacci sequence F(n), on the positive integers, are defined as such: ...
• 50k
5k views

### Is it a Proth number?

A Proth number, named after François Proth, is a number that can be expressed as $$N = k \times 2^n + 1$$ Where $k$ is an odd positive integer and $n$ is a positive integer such that $2^n > k$...
• 59.4k
9k views

### Count up folks!

Introduction It may sound strange, but we haven't got ONE challenge for counting from 1 to n, inclusive. This is not the same ...
• 40.6k
4k views

### Restricted mini challenges Cop's Thread

Robber's thread Your task as cops is to select three things: A programming language An OEIS sequence A byte set You are then to secretly write a program in that language that computes the nth term ...
• 99.4k
2k views

Perfect License Plates Starting a few years ago, I made myself a little game while driving around: checking if nearby license plates are "perfect". It's relatively rare, but exciting when you find ...
• 457
4k views

### Iterated partial sums

The partial sums of a list of integers [a1, a2, a3, ..., an] are s1 = a1 s2 = a1 + a2 s3 = a1 + a2 + a3 ... sn = a1 + a2 + ... + an We can then take the list of partial sums [s1, s2, s3, ..., sn] ...
• 146k
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 ...
• 14k