Questions tagged [sequence]

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

Filter by
Sorted by
Tagged with
31 votes
30 answers
6k 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 <...
36 votes
99 answers
4k views

Lolololololololololololol

Let us take a break from the brain-wrecking questions and answer some of the simpler ones You have recently read something extremely funny, and want to express your laughter to the world! But how can ...
107 votes
384 answers
19k 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 ...
12 votes
9 answers
587 views

AoCG2021 Day 17: Langton's Hexa-Virus

The story continues from AoC2017 Day 22, Part 2. The damn virus that was infecting a grid computing cluster now has jumped to a hexagonal computing cluster! In this cluster, the computers are ...
145 votes
302 answers
37k 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 ...
30 votes
33 answers
4k views

Smallest number such that concatenation is a square

Challenge Write a program or function that takes a number \$n\$ and returns the smallest \$k\$ such that concatenation \$n'k\$ is a square. This sequence is described by A071176 on the OEIS. I/O ...
31 votes
37 answers
5k views

Is it a semiprime?

Surprisingly, I don't think we have a code-golf question for determining if a number is semiprime. A semiprime is a natural number that is the product of two (not necessarily distinct) prime ...
18 votes
13 answers
2k views
+100

Straighten my corners... diagonally

We can arrange the positive integers like this: 1_| 2 | 5 | 10 4___3_| 6 | 11 9___8___7_| 12 16 15 14 13 That is, in L-shaped brackets expanding down and right ...
27 votes
41 answers
2k views

Invalid Invali Inval

This idea is loosely based upon @TùxCräftîñg's chat message. Take a look at the below example sequence: INVALID0, INVALID1, <...
17 votes
12 answers
970 views

Enumerate all pure sets

In set theory, a set is an unordered group of unique elements. A pure set is either the empty set \$\{\}\$ or a set containing only pure sets, like \$\{\{\},\{\{\}\}\}\$. Your challenge is to write a ...
17 votes
15 answers
2k views

Concatenatable numbers

Given a list of positive integers such as [69, 420], your challenge is to generate the sequence of numbers that can be formed by concatenating numbers from the ...
24 votes
20 answers
2k views

Reconstruct an arithmetic sequence

Given a finite arithmetic sequence of positive integers with some terms removed from the middle, reconstruct the whole sequence. The task Consider an arithmetic sequence: a list of positive integers ...
25 votes
19 answers
3k views

Divinacci Sequence

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

Number of complete rhyme schemes

A rhyme scheme is the pattern of rhymes at the end of the lines in a poem. They are typically represented using letters, like ABAB. We consider two rhyme schemes ...
13 votes
12 answers
693 views

Count alternating permutations

An alternating permutation is a permutation of the first \$ n \$ integers \$ \{ 1 ... n \} \$, such that adjacent pairs of values in the permutation alternate between increasing and decreasing (or ...
10 votes
7 answers
650 views

Make an n-Juggler

I've been really interested with sequences that follow the property \$a(n+1) = a(n - a(n))\$ recently, so here's another question about these sequences. In particular we are concerned with ...
30 votes
34 answers
2k views

Parenthifiable Binary Numbers

If you express some positive integer in binary with no leading zeros and replace every 1 with a ( and every ...
26 votes
30 answers
2k views

Not so triangular numbers

Let's consider the sequence \$S\$ consisting of one \$1\$ and one \$0\$, followed by two \$1\$'s and two \$0\$'s, and so on: $$1,0,1,1,0,0,1,1,1,0,0,0,1,1,1,1,0,0,0,0,...$$ (This is A118175: Binary ...
24 votes
14 answers
2k views

Emanresu numbers

My userid is 100664. In binary this is 11000100100111000. An interesting property of this number is that it can be created entirely by concatenating strings which ...
28 votes
16 answers
2k views

Output the Euler Numbers

Given a non-negative integer \$n ,\$ output the \$n^{\text{th}}\$ Euler number (OEIS A122045). All odd-indexed Euler numbers are \$0 .\$ The even-indexed Euler numbers can be computed with the ...
7 votes
24 answers
2k views

Find the nth Fibonacci number, where n is the mth Fibonacci number

Introduction If \$\newcommand{\fib}{\operatorname{fib}}\fib(x)\$ calculates the \$x\$th Fibonacci number, write a program that calculates \$\fib(\fib(m))\$ for any integer value of \$m \ge 0\$. (Of ...
43 votes
42 answers
12k views

Fibonacci reversed!

Introduction We all know and love our Fibonacci sequence and have seen a myriad of challenge on it here already. However, we're still lacking a very simple case which this answer is going to provide: ...
27 votes
23 answers
2k views

Output the Iccanobif Sequence

Write a program or named function that will output or return the sequence up to the nth integer in the Iccanobif sequence, documented on OEIS as A014258. Note that ...
19 votes
30 answers
2k views

Output the Juggler sequence

The Juggler sequence is described as follows. Beginning with an input \$a_1\$, the next term is defined by the recurrence relation $$a_{k+1} = \begin{cases} \left\lfloor a_k ^ \frac 1 2 \right\rfloor,\...
17 votes
35 answers
2k views

Incremental Ranges!

Your task is to, given two positive integers, \$x\$ and \$n\$, return the first \$x\$ numbers in the incremental ranges sequence. The incremental range sequence first generates a range from one to \$...
20 votes
2 answers
480 views

Maximal Substring Construction

In this challenge, you are passed two things: A string length, N A list of strings, L, each with an assigned point value. Any ...
18 votes
27 answers
1k views

Output a unique sign sequence

A sign sequence is an infinite sequence consisting entirely of \$1\$ and \$-1\$. These can be constructed a number of ways, for example: Alternating signs: \$1, -1, 1, -1, ...\$ \$-1\$ for primes, \$...
6 votes
1 answer
333 views

Irradiated Polyglots

Design a function or program that, when run normally, outputs the triangular numbers. However, when any single character is deleted, the program/function should not function in the original ...
19 votes
15 answers
2k views

Euler's numerus idoneus

Euler's numerus idoneus, or idoneal numbers, are a finite set of numbers whose exact number is unknown, as it depends on whether or not the Generalized Riemann hypothesis holds or not. If it does, ...
22 votes
27 answers
2k views

Perfect radicals

Given a positive integer number \$n\$ output its perfect radical. Definition A perfect radical \$r\$ of a positive integer \$n\$ is the lowest integer root of \$n\$ of any index \$i\$: $$r = \sqrt[i]{...
4 votes
18 answers
2k views

Palindromic Powers

Powers We define an important power as a number that can be represented as \$ x^y \$ where \$ x ≥ 2 \$ and \$ y ≥ 2 \$. Palindrome We define an ...
41 votes
32 answers
3k views

Compute the Digit Difference Sum of a Number

Consider taking some non-negative integer such as 8675309 and computing the absolute values of the differences between all the pairs of neighboring digits. For \$8675309\$ we get \$|8-6| = 2\$, \$|6-7|...
22 votes
27 answers
3k views

How many threes?

In this task your code will be given an integer \$n\$ as input. Your code should then output the greatest number of multiples of \$3\$ that can be concatenated (in base \$10\$) to form \$3n\$ (with ...
32 votes
51 answers
4k views

Multiply or Divide by n

Here's a simple challenge, so hopefully lots of languages will be able to participate. Given a positive integer \$n\$, output \$A076039(n)\$ from the OEIS. That is, start with \$a(1)=1\$. Then for \$n&...
29 votes
20 answers
2k views

An ASCII self-referential sequence

The sequence A109648 starts with the following numbers ...
12 votes
17 answers
2k views

Infinite Candle Sequence

I have a cake shop that specialises in birthday cakes. The cakes that I sell must have candles placed in a circle. You would probably think I can just divide 360° by the number of candles, but the ...
18 votes
33 answers
2k views

Reverse and square

In this challenge you will compute numbers from a curious sequence. Your input is a single decimal nonnegative integer. Reverse the bits in this integer and then square the number to get the required ...
15 votes
24 answers
2k views

The Binary Eyes

A binary eye is an odd set of digits, with all of its digits except the center one set to 1 or 0, and the center one set to the opposite of the others. Thus, there are two binary eyes for a given odd ...
22 votes
9 answers
957 views

Sequence of integers not the sum of powers of earlier terms

Starting with 1, output the sequence of integers which cannot be represented as the sum of powers of earlier terms. Each previous term can be used at most once, and the exponents must be non-negative ...
44 votes
46 answers
5k views

The Rien Number

The Champernowne constant is a number that is constructed by concatenating the first n numbers, with n tending to infinity. It ...
56 votes
251 answers
16k 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 ...
25 votes
29 answers
3k views

Make me a metasequence

Background For this challenge, a 'metasequence' will be defined as a sequence of numbers where not only the numbers themselves will increase, but also the increment, and the increment will increase by ...
34 votes
52 answers
5k views

The first n numbers without consecutive equal binary digits

The sequence contains the decimal representation of the binary numbers of the form: 10101..., where the n-th term has n bits. The sequence is probably easiest to ...
21 votes
21 answers
5k 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 ...
40 votes
54 answers
7k 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 ...
15 votes
10 answers
1k views

The Lehmer-Comtet sequence

The Lehmer-Comtet sequence is a sequence such that a(n) is the nth derivative of f(x) = xx with respect to x as evaluated at x = 1. Task Take a non-negative integer as input and output the nth term ...
18 votes
15 answers
3k views

Join my exclusive friendly club!

Two or more positive integers are said to be "friendly" if they have the same "abundancy". The abundancy of an positive integer \$n\$ is defined as $$\frac {\sigma(n)} n,$$ where \$...
45 votes
69 answers
4k views

Fibonacci-orial

Definition Fibonacci sequence F(n), on the positive integers, are defined as such: ...
29 votes
18 answers
4k views

Infinitely many primes

Since Euclid, we have known that there are infinitely many primes. The argument is by contradiction: If there are only finitely many, let's say \$p_1,p_2,...,p_n\$, then surely \$m:=p_1\cdot p_2\cdot.....
44 votes
77 answers
8k views

Print a bunch of uninteresting numbers!

An uninteresting number (which I totally didn't make up only for this challenge) is created like this: Take a positive integer N Create a new number O by adding the digits of N at the end of N ...

1
2 3 4 5
17