Questions tagged [sequence]
For challenges involving sequences, typically of numbers following some pattern.
944
questions
14
votes
10
answers
1k
views
Sylvester primes
Sylvester's sequence can be defined recursively S(n) = S(n-1)*(S(n-1) + 1) for n >= 1 starting S(0) = 1.
Since S(n) and S(n) + 1 have no common divisors, it follows that S(n) has at least one more ...
15
votes
15
answers
1k
views
Sums of X*Y chunks of the nonnegative integers
Consider the infinite table of the nonnegative integers with width 12:
...
14
votes
16
answers
564
views
Rabinowitz-Wagon \$\pi\$ formula
In 1995, Stanley Rabinowitz and Stan Wagon found an interesting algorithm to generate the digits of \$\pi\$ one by one without storing the previous results. The algorithm is called the spigot ...
3
votes
2
answers
219
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\$ ...
14
votes
5
answers
377
views
Generate a subgroup of a free group
In group theory, the free group with \$n\$ generators can be obtained by taking \$n\$ distinct symbols (let's call them \$a, b, c ...\$ etc), along with their inverses \$ a^{-1},b^{-1},c^{-1} ...\$ . ...
17
votes
24
answers
2k
views
Smallest Harmonic number greater than N
The sequence of Harmonic numbers are the sums of the reciprocals of the first k natural numbers (not including zero):
\${\displaystyle H_{k}=1+{\frac {1}{2}}+{\frac {1}{3}}+\cdots +{\frac {1}{k}}=\sum ...
18
votes
18
answers
1k
views
Output the inventory sequence
Goal
Write a program that outputs this list:
...
15
votes
2
answers
397
views
Where are zeros? Self-describing sequence
Background
A167519: Lexicographically earliest increasing sequence which lists the positions of the zero digits in the sequence.
...
16
votes
6
answers
1k
views
Golfing the complexity with subtraction
The Mahler-Popken complexity, \$C(N)\$, of a positive integer, \$N\$, is the smallest number of ones (\$1\$) that can be used to form \$N\$ in a mathematical expression using only the integer* \$1\$ ...
13
votes
11
answers
804
views
*Trivial* near-repdigit perfect powers
Task
Output the sequence that precisely consists of the following integers in increasing order:
the 2nd and higher powers of 10 (\$10^i\$ where \$i \ge 2\$),
the squares of powers of 10 times 2 or 3 (...
14
votes
10
answers
1k
views
Enumerate all matches of a regex
related
For this challenge, we'll be using a simplified dialect of regular expressions, where:
A lowercase letter from a to z ...
10
votes
4
answers
2k
views
Output a 1-2-3-5-7... sequence
Follow-up of my previous challenge, inspired by @emanresu A's question, and proven possible by @att (Mathematica solution linked)
For the purposes of this challenge, a 1-2-3-5-7... sequence is an ...
21
votes
15
answers
2k
views
Output a 1-2-3 sequence
For the purposes of this challenge, a 1-2-3 sequence is an infinite sequence of increasing positive integers such that for any positive integer \$n\$, exactly one of \$n, 2n,\$ and \$3n\$ appears in ...
13
votes
12
answers
2k
views
Odds for second smallest prime factor
Given a prime number \$p\$ output the asymptotic density of the set of positive integers which have \$p\$ as their second-smallest distinct prime factor
Input/Output
Input: one of the following ...
2
votes
3
answers
212
views
Rank poker High Card hands [closed]
In the poker game there are 1277 unique 'High Card' ranks. It's 1287 (13 over 5) if we include all straights.
The challenge is to write a function which returns an integer value corresponding to the ...
14
votes
7
answers
2k
views
How quickly can you type this unary string?
If I want to type the string aaa, the least keystrokes I can type it in is 3: a a a. But if I want to type the string ...
15
votes
16
answers
1k
views
Pretty Palintiples
Imagine you have a positive integer number \$n\$. Let \$m\$ be the number obtained by reversing \$n\$'s digits. If \$m\$ is a whole multiple of \$n\$, then \$n\$ is said to be a reverse divisible ...
10
votes
13
answers
1k
views
Enumerate the Phat-fingered-lights-out numbers
Even though the concept of phat-fingered-lights-out number should be pretty self-explanatory here is a definition:
Given a nonnegative integer in binary representation a phat-fingered double-bit-flip ...
1
vote
8
answers
304
views
Alternating Random Series Sum To \$N\$ [closed]
Challenge
Given a positive integer \$N \ge 3\$, generate an alternating series of \$N\$ random numbers within the range \$[1, N]\$, such that their sum equals \$N\$. Expressed mathematically as
$$N = ...
5
votes
5
answers
718
views
Double-reduce a sequence of integers
Consider a function \$r\$ where
$$
r(i,k)= \begin{cases}
L_{i+1}-L_i, & \text{if}\ k =0\ \text{ (1st reduction)} \\
r(i,0)-r(\lfloor \log_2{k} \rfloor,k-2^{\lfloor \log_2{k} \rfloor}) & \text{...
13
votes
14
answers
612
views
Binary Expansion Counting Sequence
I found another sequence not yet in the OEIS
The binary expansion sequence is defines as follows, assuming 0 indexing:
The even numbers of the sequence are how often 0 has appeared in the binary ...
19
votes
22
answers
2k
views
Mousetail's Sequence
I define mousetail's sequence as follows:
If the nth element of the sequence is q, then n+1 must appear q times in the sequence
The sequence is weakly monotonically increasing (i.e. no lower number ...
1
vote
0
answers
151
views
Exact Sum of 1/2 to 1/n [duplicate]
Consider the sequence 1/2, 1/3 + 1/2, 1/4 + 1/3 + 1/2, and so on. In mathematical symbols, this is
$$S(n)=\sum_{m=2}^{n+1}\frac{1}{m}$$
where S is the function that makes the sequence.
Outputting this ...
9
votes
12
answers
1k
views
How many Carlitz compositions are there?
OEIS sequence A003242 comprises the numbers of Carlitz compositions for any given positive integer. This is the number of integer partitions of the integer for which no two adjacent parts are equal.
...
19
votes
9
answers
992
views
Output an infinitely proportional sequence
In this challenge, an infinitely proportional sequence is defined as a infinite sequence of positive integers such that:
All positive integers are contained infinitely many times within the sequence.
...
18
votes
24
answers
2k
views
Test whether a sequence is bitonic
You know what a monotonic sequence is: each element is bigger than its predecessor (monotonically rising) or as its successor (monotonically falling).
Bitonic means you have two arms of the sequence, ...
14
votes
1
answer
279
views
Construct the Constructability sequence
Consider compass-and-straightedge construction, where you can construct new points from existing ones by examining intersections of straight lines and circles constructed with one of the following two ...
18
votes
39
answers
2k
views
Rudin-Shapiro sequence
The Rudin-Shapiro sequence is a sequence of \$1\$s and \$-1\$s defined as follows: \$r_n = (-1)^{u_n}\$, where \$u_n\$ is the number of occurrences of (possibly overlapping) \$11\$ in the binary ...
17
votes
23
answers
2k
views
Monotone sequence beatitude
Provided that the input is a monotone sequence of three or more integers:
Output -2 if the sequence strictly decreases. Example: [7,4,3,2]
Output -1 if the ...
5
votes
9
answers
4k
views
Minecraft XP Orb Amounts
In the video game Minecraft, the player can obtain experience points (XP) from various activities. In the game, these are provided as XP "orbs" of various sizes, each of which give the ...
16
votes
18
answers
2k
views
Divisor chain counts (1 3 3 7 ...)
The divisors of a natural number form a poset under the relation of "a divides b?", \$a | b\$. This challenge is to produce the number, \$C\$, of non-empty chains of such posets for natural ...
20
votes
23
answers
2k
views
Diagonal Binary Sequence
Challenge:
Given a positive number \$n\$, convert it to binary, and output a sequence where all 1s form a top-left to bottom-right diagonal line, including a ...
9
votes
9
answers
2k
views
Make a super fair number
An even distribution number is a number such that if you select any of it's digits at random the probability of it being any particular value (e.g. 0 or ...
15
votes
14
answers
1k
views
The multiples are missing
Given a number \$n\$, you are to compute the sequence of positive numbers where for each number \$a\$, the \$n\$-times multiple \$n\cdot a\$ is missing.
Example
We always start with the sequence of ...
18
votes
20
answers
2k
views
Complement an infinite list
In this challenge, we define the complement of a list of positive integers as all positive integers not included in that list. For example, the complement of the even numbers ...
10
votes
7
answers
782
views
Longest sequence of Egyptian fractions with n as denominator
Background
From Wikipedia: An Egyptian fraction is the sum of distinct unit fractions. That is, each fraction in the expression has a numerator equal to 1 and a denominator that is a positive integer, ...
16
votes
10
answers
1k
views
Find the longest permutations of integers from 1..k such that all neighbouring pairs sum to a square
OEIS A090461 details the ‘numbers k for which there exists a permutation of the numbers 1 to k such that the sum of adjacent numbers is a square’. This has also been the subject of Matt Parker’s ...
10
votes
16
answers
1k
views
Numbers with distinct decimal digits
Write a program or function that outputs all positive integers with distinct decimal digits (OEIS: A010784)
Examples:
...
14
votes
18
answers
2k
views
Golf the fast growing hierarchy
The fast growing hierarchy is a way of categorizing how fast functions are growing,
defined the following way (for finite indices):
\$ f_0(n)=n+1 \$
\$ f_k(n)=f_{k-1}^n(n)\$ with \$f^n\$ meaning ...
9
votes
11
answers
744
views
Otteretto Classic game scoring method
Brief description of the game
In the game Otteretto Classic (which you can test directly in your browser; try it!) the player has to form palindromic sequences using adjacent cells on a square grid. ...
8
votes
20
answers
1k
views
Piecing Paired Primes
Problem
You've stumbled upon a paradoxical mathematical phenomenon related to prime numbers. Consider the following scenario:
You have an infinite list of prime numbers: $$2, 3, 5, 7, 11, 13, 17, 19, ....
13
votes
9
answers
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:
...
11
votes
14
answers
3k
views
Encrypting Emojis
Problem
You are tasked with creating a program that performs emoji encryption on a given string of emojis. In this encryption scheme, each emoji is replaced by a unique character (from ...
15
votes
16
answers
846
views
Output the smallest increasing sequence where each term is coprime to preceding 3 terms
This sequence is defined as
Starts with 1, 2, 3
The next element of the sequence is the first number greater than the previous three that is co-prime with each of the previous 3 elements in the ...
8
votes
8
answers
659
views
Magic OEIS formulae (Robbers' thread)
This is the robbers' thread. See the cops' thread here.
In this cops and robbers challenge, the cops will be tasked with writing an algorithm that computes some function of their choice, while the ...
12
votes
9
answers
772
views
Magic OEIS formulae (Cops' thread)
This is the cops' thread. See the robbers' thread here.
In this cops and robbers challenge, the cops will be tasked with writing an algorithm that computes some function of their choice, while the ...
11
votes
12
answers
1k
views
The all-high powerful numbers
We've had powerful numbers, yes, but what about highly powerful numbers?
Highly powerful numbers
Let \$n\$ be a positive integer in the form
$$n = p_1^{e_{p_1}(n)}p_2^{e_{p_2}(n)}\cdots p_k^{e_{p_k}(n)...
20
votes
5
answers
1k
views
Repeating occupied pattern in Hilbert's hotel
Imagine a countable infinite amount of empty rooms. When an infinite amount of guests come, they occupy the 1st, 3rd, 5th...(all odd) empty rooms. Therefore there's always an infinite amount of empty ...
33
votes
36
answers
2k
views
Make a k-skip-j range
On the Mathematica Stack Exchange, 100xln2 asks:
I need a list of integers […] The list contains integers and is characterized by [three] parameters, lets call them k and j [and listmax], which ...
14
votes
14
answers
2k
views
Print all Polynomials
The set of all polynomials with integer coefficients is countable.
This means that there is a sequence that contains each polynomial with integer coefficients exactly once.
Your goal is it to write a ...