Questions tagged [sequence]

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

Filter by
Sorted by
Tagged with
4 votes
16 answers
218 views

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

Introduction If fib(x) calculates the xth Fibonacci number, write a program that calculates ...
user avatar
  • 149
5 votes
1 answer
226 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 ...
user avatar
  • 1,190
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 ...
user avatar
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 ...
user avatar
22 votes
9 answers
945 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 ...
user avatar
  • 411
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 ...
user avatar
  • 457
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 \$...
user avatar
22 votes
12 answers
2k views

How many Sieve of Eratosthenes hits?

Sieve of Eratosthenes is a method for finding prime numbers: take the sequence of all positive integer numbers starting from 2 then for each remaining number drop all its multiples. ...
user avatar
  • 9,426
10 votes
7 answers
274 views

Maximum population of a \$n \times n\$ still life in Conway's Game of Life

This is OEIS sequence A055397. In Conway's Game of life, a still life is a pattern that does not change over time. We can see from the rules of Conway's Game of life that, a pattern is a still life if ...
user avatar
  • 32.7k
9 votes
11 answers
1k views

Smallest numbers whose square has even number of digits

...
user avatar
  • 9,426
18 votes
15 answers
1k views

Long period primes

A long period prime is a prime number \$p\$ such that decimal expansion of \$1/p\$ has period of length \$(p-1)\$. Your task is to output this number sequence. For purposes of this challenge we will ...
user avatar
  • 10.7k
22 votes
17 answers
941 views

Pairs of integers ordered by their exponentiation

Output the infinite list of pairs of integers (a, b), where both \$ a > 1 \$ and \$ b > 1 \$, ordered by the value of \$ a^b \$. When there are multiple pairs ...
user avatar
  • 18.3k
29 votes
16 answers
2k views

How-many-bonacci-like is this sequence?

Inspired by @emanresu A's Is it a fibonacci-like sequence? Make sure to upvote that challenge as well! We say a sequence is Fibonacci-like, if, starting from the third term (\$1\$-indexed), each term ...
user avatar
  • 32.7k
16 votes
26 answers
988 views

Sum of the first n elements of the sequence of 9's complement

Let's consider the following sequence: $$9,8,7,6,5,4,3,2,1,0,89,88,87,86,85,84,83,82,81,80,79,78,77,76,75,74,73,72,71...$$ This is the sequence of \$9\$'s complement of a number: that is, \$ a(x) = 10^...
user avatar
  • 1,555
14 votes
15 answers
1k views

How many blocks make a "truncated square-pyramid garden"?

A truncated square-pyramid of height \$h\$ has \$h\$ square layers where each layer has a side \$1\$ greater than the one above it, apart from the top layer which is a square of blocks with a given ...
user avatar
12 votes
8 answers
791 views

All sequences as substrings

Make a program that outputs a sequence of integers so that every finite sequence of positive integers is a substring (continuous subsequence) of the output. For example, the following sequence ...
user avatar
  • 6,645
16 votes
4 answers
564 views

Probability breaking sequences

If we have a finite list of elements we can determine the probability of any one element being drawn at random as the number of times it occurs divided by the total number of elements in the list. For ...
user avatar
  • 84.6k
16 votes
13 answers
1k views

Square-free words of a length

A square-free word is a word consisting of arbitrary symbols where the pattern \$XX\$ (for an arbitrary non-empty word \$X\$) does not appear. This pattern is termed a "square". For example, ...
user avatar
21 votes
13 answers
2k 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 ...
user avatar
  • 84.6k
9 votes
1 answer
341 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, ...
user avatar
6 votes
10 answers
763 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: ...
user avatar
  • 2,493
18 votes
16 answers
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 ...
user avatar
  • 84.6k
-6 votes
4 answers
150 views

Indices of square numbers that are also pentagonal [closed]

First 15 numbers of the A046173: ...
user avatar
  • 3,031
17 votes
6 answers
746 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 ...
user avatar
  • 84.6k
23 votes
27 answers
2k views

Next Greater Number

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, is ...
user avatar
  • 3,031
16 votes
13 answers
997 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 ...
user avatar
  • 18.3k
18 votes
2 answers
585 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-...
user avatar
  • 62.1k
29 votes
20 answers
2k views

An ASCII self-referential sequence

The sequence A109648 starts with the following numbers ...
user avatar
  • 62.1k
12 votes
7 answers
219 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\$. ...
user avatar
14 votes
4 answers
439 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 ...
user avatar
  • 6,645
29 votes
12 answers
1k 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 ...
user avatar
  • 3,053
12 votes
9 answers
574 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 ...
user avatar
  • 62.1k
28 votes
25 answers
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(...
user avatar
  • 26.7k
15 votes
15 answers
970 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 ...
user avatar
  • 26.7k
28 votes
10 answers
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 ...
user avatar
  • 1,995
18 votes
23 answers
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 ...
user avatar
  • 21k
14 votes
9 answers
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 ...
user avatar
  • 10.7k
17 votes
13 answers
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: ...
user avatar
  • 62.1k
16 votes
19 answers
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 ...
user avatar
1 vote
2 answers
104 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 ...
user avatar
  • 169
10 votes
1 answer
264 views

Concatenation Coincidence

This code-golf challenge (and test cases) are inspired by the work of Project Euler users amagri, Cees.Duivenvoorde, and oozk, and Project Euler Problem 751. (And no, this isn't on OEIS). Sandbox A ...
user avatar
17 votes
11 answers
2k views

Binary triangle A141727

Challenge Generate the 2D sequence of bits of A141727. (Allowed I/O methods explained at the bottom.) ...
user avatar
  • 62.1k
15 votes
14 answers
2k views

Inverse n-bonacci sequence

We all know about the Fibonacci sequence. We start with two 1s and keep getting the next element with the sum of previous two elements. n-bonacci sequence can be defined in similar way, we start with <...
user avatar
  • 169
16 votes
15 answers
2k views

Print Gobar Primes

Gobar primes (A347476) are numbers which give a prime number when 0's and 1's are interchanged in their binary representation. For example, \$10 = 1010_2\$, and if we flip the bits, we get \$0101_2 = ...
user avatar
  • 193
21 votes
9 answers
1k views

Self-referential triangle sequence

Output the flattened version of the sequence A297359, which starts like the following: ...
user avatar
  • 62.1k
13 votes
8 answers
1k views

Find the number of paths in a n×n grid

Information Given a non-negative odd integer (let's call it \$n\$), find the number of all possible paths which covers all squares and get from the start to end on a grid. The grid is of size \$n\$×\$...
user avatar
  • 1,581
15 votes
7 answers
3k views

Make S + S + ... + S as Large as Possible!

Let \$S \subset \mathbb N_{\geq0}\$ be a subset of the nonnegative integers, and let $$ S^{(k)} = \underbrace{S + S + \dots + S}_{k\ \textrm{times}} = \{ a_1 + a_2 + \dots + a_k : a_i \in S\}. $$ For ...
user avatar
  • 8,097
16 votes
7 answers
869 views

Maybe fractal sequence?

Background A fractal sequence (Wikipedia; MathWorld) is an infinite sequence of positive integers meeting the following conditions: Each positive integer appears infinitely many times in the sequence....
user avatar
  • 62.1k
26 votes
32 answers
2k views

Triple countdown sequence

Let's start with the natural numbers ...
user avatar
  • 84.6k
22 votes
12 answers
2k views

Greedy queens sequence

Challenge Implement the "greedy queens" sequence (OEIS: A065188). Details Taken from the OEIS page. This permutation [of natural numbers] is produced by a simple greedy algorithm: starting ...
user avatar
  • 10.7k

1
2 3 4 5
17