Questions tagged [sequence]

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

Filter by
Sorted by
Tagged with
27
votes
31answers
3k views

Deranged !Combinatorics: Compute the Subfactorial

The subfactorial or rencontres numbers (A000166) are a sequence of numbers similar to the factorial numbers which show up in the combinatorics of permutations. In particular the nth subfactorial !n ...
36
votes
34answers
2k views

Ken Iverson’s Favourite APL Expression?

Ken Iverson, 1920–2020 Let's implement his favourite expression: Given a row of Pascal's triangle, compute the next row. This can for example be computed by taking the input padded with a zero on the ...
29
votes
3answers
1k views

Placing circles along a square spiral

In this code golf challenge, you'll be computing the placement of circles of areas \$\pi, 2\pi, 3\pi, \dots\$ when greedily placed along integer points in a square spiral in such a way that no two ...
14
votes
13answers
916 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 ...
41
votes
44answers
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 ...
27
votes
33answers
5k views
+100

Numbers divisible by the sum and product of their digits

Take a positive integer X. This number is part of the sequence we are interested in if the sum of all digits of X is a divisor ...
19
votes
10answers
1k views

Output every sublist ... eventually

You will be given as input an infinite stream of positive integers. Your task is to write a program which outputs an infinite sequence of lists with two requirements: All lists in the output are ...
3
votes
9answers
668 views

Generate Fmbalbuena Numbers

My user id is 106959 How to check if the number is Fmbalbuena number? First Step: Check if the number of digits is a multiple of 3: ...
9
votes
1answer
328 views

Universal Command Sequence

Universal Command Sequence Definition An \$n\$-maze is a \$n\times n\$ chessboard which has "walls" on some edges, and a "king" on the board that can move to the 4 adjacent cells, ...
19
votes
46answers
2k views

Generate list of numbers and their negative counterparts

A recent SO question asks for a convenient one-liner to generate a list of numbers and their negative counterparts in Python. Given two integers \$1≤a≤b\$, generate all the integers \$x\$ such that \$...
18
votes
16answers
1k views

Slater-Velez permutation

Let's build a sequence of positive integers. The rule will be that the next number will be the smallest number which: It hasn't already appeared in the sequence Its absolute difference from the ...
-6
votes
4answers
114 views

Indices of square numbers that are also pentagonal [closed]

First 15 numbers of the A046173: ...
21
votes
24answers
2k views

Next Greater Number

The task: Given an integer n, find the next number that follows the following requirements The next greater number is a number where each digit, from left to right,...
106
votes
369answers
18k 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 ...
16
votes
6answers
729 views

Mutually recursive lists

Let's define a simple function \$f\$ which takes an integer and produces a list: \$ f(n) = [g(1),g(2),\dots,g(n)] \\ g(n) = [f(0),f(1),\dots,f(n-1)] \$ We can then calculate the first couple of values ...
136
votes
284answers
35k 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 ...
27
votes
20answers
2k views

An ASCII self-referential sequence

The sequence A109648 starts with the following numbers ...
13
votes
16answers
861 views

Alternested numbers

Consider the array of positive integers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ... Then, concatenate them: ...
16
votes
27answers
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, \$...
23
votes
53answers
3k views

Find the sum of the divisors of N

Write a program that displays on the screen the sum of the divisors of a number (1 ≤ N ≤ 100) entered by the user in the range of 1 to N. This is OEIS A000203. Examples: Input: 7 ...
33
votes
0answers
948 views

Topologically distinct ways of dissecting a square into rectangles

I was asked by OEIS contributor Andrew Howroyd to post a Code Golf Challenge to extend OEIS sequence A049021. Would be super great to get a couple more terms for [...] A049021. Kind of thing [...] ...
15
votes
1answer
378 views

Counting universal n-ary logic gates

Background A classical logic gate is an idealized electronic device implementing a Boolean function, i.e. one that takes a certain number of Boolean inputs and outputs a Boolean. We only consider two-...
45
votes
54answers
3k views

Output integers in negative order, increase the maximum integer everytime

Main task Your task is to print out integers in descending order, starting from 1, and increasing as you keep hitting 1 again, up until the given input is reached, then, print out the rest until you ...
34
votes
51answers
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 ...
33
votes
83answers
3k 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 ...
25
votes
12answers
5k views

Hamming numbers

Given a positive integer, print that many Hamming numbers, in order. Rules: Input will be a positive integer \$n \le 1,000,000 \$ Output should be the first \$n\$ terms of https://oeis.org/A051037 ...
25
votes
25answers
2k views

Converge to a number

Your challenge is to, given a positive integer n, count up to each digit of it, giving the effect of converging on it. Basically, count up to the first digit of n by its place value (\$⌊\log_{10}\left(...
15
votes
18answers
2k views

Prime Factoral Roots

Inspired by digital roots, the prime factoral root of a number is the number that emerges when you take the prime factors of a number, add them together, and repeat the process on the resulting number,...
15
votes
20answers
1k views

Create a pointer sequence

Lets define a pointer sequence to be any sequence such that a(n) = a((n-1)-(a(n-1))) forall n greater than some finite number. For example if our sequence begun with ...
24
votes
31answers
2k views

Triple countdown sequence

Let's start with the natural numbers ...
12
votes
4answers
368 views

The Most Wanted Prime Numbers

Output a sequence of all the primes that are of the following form: 123...91011...(n-1)n(n-1)..11109...321. That is, ascending decimal numbers up to some ...
10
votes
7answers
207 views

Multiplicity of Shared Totients

Euler's totient function, \$\varphi(n)\$, counts the number of integers \$1 \le k \le n\$ such that \$\gcd(k, n) = 1\$. For example, \$\varphi(9) = 6\$ as \$1,2,4,5,7,8\$ are all coprime to \$9\$. ...
10
votes
9answers
518 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 ...
24
votes
12answers
975 views

Nth FizzBuzz Number

Introduction Everyone knows the FizzBuzz sequence. It goes something like this: 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz . . . In case you don't ...
13
votes
9answers
2k views

All distances different on a chessboard

Inspired by this Puzzling SE question: All distances different on a chess board. Introduction Lets define a sequence \$a(n), n\geqslant 1\$ as how many pawns can you put on a \$n \times n\$ chessboard ...
14
votes
15answers
950 views

Fully matched numbers

For the context of this challenge, a matched group is a digit \$n\$, followed by \$n\$ more matched groups. In the case of \$n = 0\$, that's the whole matched group. Digits only go up to 9. For ...
26
votes
10answers
2k views

Sum powers to n

Each natural number (including 0) can be written as a sum of distinct powers of integers (with a minimum exponent of 2). Your task is to output the smallest power required to represent \$n\$. For ...
44
votes
64answers
6k 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: ...
27
votes
40answers
4k views

The plus-minus sequence

The plus-minus sequence The plus-minus sequence is one that starts with two seeds, a(0) and b(0). Each iteration of this ...
15
votes
19answers
2k views

Harmonic divisor numbers

Consider the \$4\$ divisors of \$6\$: \$1, 2, 3, 6\$. We can calculate the harmonic mean of these numbers as $$\frac 4 {\frac 1 1 + \frac 1 2 + \frac 1 3 + \frac 1 6} = \frac 4 {\frac {12} 6} = \frac ...
31
votes
2answers
987 views

A spiral sequence

Background OEIS sequence A272573 describes a spiral on a hexagonal grid as follows: Start a spiral of numbers on a hexagonal tiling, with the initial hexagon as a(1) = 1. a(n) is the smallest ...
17
votes
23answers
1k views

AoCG2021 Day 3: Say-Look-Say

Part of Advent of Code Golf 2021 event. See the linked meta post for details. Related to AoC2015 Day 10. Here's why I'm posting and not Bubbler The Elves are playing a variation of the game called ...
7
votes
2answers
3k views

Quickly find length of n-th term of the look-and-say sequence

The look and say sequence is an example of a run length encoding sequence. To get the next term of the sequence one groups the sequence into runs of the same number, each group in the next term then ...
18
votes
21answers
987 views

Binomial transform

Background Binomial transform is a transform on a finite or infinite integer sequence, which yields another integer sequence. The binomial transform of a sequence \$\{a_n\}\$ is given by $$s_n = \sum_{...
24
votes
23answers
2k views

Complete a sequence using its distances

Given \$A = (a_1,\dots,a_k)\ k\ge2 \$ a sequence of positive integers, in which all elements are different. Starting from \$i=2\$, while \$a_i\in A:\$ (until the last element) If \$d=|a_i-a_{i-1}|\$ ...
10
votes
13answers
702 views

'Plane' the numbers in any base!

Inspired by this Numberphile video. What is planing? In order to 'plane' a sequence of digits, you need to: Identify the lengths of the 'runs' (adjacently repeated digits) in the sequence. Non-...
15
votes
16answers
2k views

Exponentiation Sequence

The oldest Polish salt mine, located in Bochnia*, was started in year 1248, which we can consider a magical number. We can see that it's equal to 4 digits from the sequence of exponentiations: . As ...
16
votes
13answers
4k views

Worst case of Slowsort

Background Slowsort is an in-place, stable sorting algorithm that has worse-than-polynomial time complexity. The pseudocode for Slowsort looks like this: ...
15
votes
6answers
1k views

The Untouchables

Untouchable Numbersα An untouchable number is a positive integer that cannot be expressed as the sum of all the proper divisors of any positive integer (including the untouchable number itself). ...
1
vote
2answers
103 views

When the result will reach the people? [closed]

Assume the result of an exam has been published. After 5 minutes, First person knows the result. In next 5 minutes, new 8 persons know the result, and in total 9 know it. Again after 5 minutes, new 27 ...

1
2 3 4 5
17