Questions tagged [sequence]

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

Filter by
Sorted by
Tagged with
12 votes
5 answers
508 views

Enumeration of free polyominoes

A polyomino with \$n\$ cells is a shape consisting of \$n\$ equal squares connected edge to edge. No free polyomino is the rotation, translation or reflection (or a combination of these ...
math scat's user avatar
  • 9,228
11 votes
4 answers
625 views

Doors and guards

Related but noticeably different You are the leader of the guard in the dungeon of an ancient castle. There are N doors in the dungeon and ...
lesobrod's user avatar
  • 3,383
10 votes
5 answers
612 views

Record Least Uncommon Multiple Counts

The Greatest Common Divisor, or gcd, of two positive integers \$x\$ and \$y\$ is the largest positive integer that divides both \$x\$ and \$y\$. The Least Common Multiple, or lcm, of two positive ...
Kip the Malamute's user avatar
16 votes
7 answers
1k views

Largest Binary Area

Take the sequence of all natural numbers in binary, (1, 10, 11, ..) then write them vertically beside each-other like this (least significant bit on top; 0s have ...
mousetail's user avatar
  • 12.5k
7 votes
6 answers
386 views

Bumping Series Implementation

I have a follow-up question here from my previous question on Math SE. I am lazy enough to explain the content again, so I have used a paraphraser to explain it below: I was considering arbitrary ...
Aitzaz Imtiaz's user avatar
12 votes
18 answers
636 views

Primes with Distinct Prime Digits

There are 18 primes with distinct prime digits (A124674). Namely, they are: \$2, 3, 5, 7, 23, 37, 53, 73, 257, 523, 2357, 2753, 3257, 3527, 5237, 5273, 7253, 7523\$ Your task is to output this ...
Bob th's user avatar
  • 309
18 votes
7 answers
1k views

Fibonacci Binary Squares

I was playing with the Fibonacci sequence in binary like so (note that the binary representations are written here from smallest bit to largest bit): ...
Kip the Malamute's user avatar
13 votes
15 answers
1k views

A Fine sequence with fine interpretations

The ubiquitous Catalan numbers \$C_n\$ count the number of Dyck paths, sequences of up-steps and down-steps of length \$2n\$ that start and end on a horizontal line and never go below said line. Many ...
Parcly Taxel's user avatar
  • 3,737
12 votes
6 answers
1k views

Approximate a root of an odd degree polynomial

Every odd degree polynomial has at least one real root. However this root does not have to be a rational number so your task is to output a sequence of rational numbers that approximates it. Rules ...
AndrovT's user avatar
  • 2,796
17 votes
19 answers
3k views

Print all pandigital numbers

Given a base as input, output all pan-digital numbers. A number is pan-digital if it includes every digit in that base at least once, possibly multiple times. Every number is considered to contain an ...
mousetail's user avatar
  • 12.5k
15 votes
18 answers
2k views

Distance to the average of the next two prime numbers

Suppose we have a sequence \$P\$. Every element \$P_n\$ represents the distance between the \$n^{th}\$ prime number and the average of the next two prime numbers. For example, \$P_1\$ would be the ...
Trivaxy's user avatar
  • 487
22 votes
17 answers
3k views

Don't repeat yourself

In this challenge you will be tasked with implementing a sequence of natural numbers such that: Each number appears a natural number of times No two numbers appear the same number of times No two ...
Wheat Wizard's user avatar
  • 98.5k
23 votes
36 answers
2k views

Smallest Bit Rotation

For a given positive integer, try to find out the smallest possible rotation resulted by rotating it 0 or more bits. For example, when the given number is 177, whose binary representation is \$...
tsh's user avatar
  • 34.7k
8 votes
32 answers
1k views

Keep elements in sequence that have a letter repeated at least 3 times

Challenge: Given the input array l with a list of strings, only keep the elements in the sequence that have a letter that's repeated at least 3 times. Like ...
U13-Forward's user avatar
  • 2,001
13 votes
35 answers
753 views

Create \$n\$ sublists with the powers of two (1, 2, 4, 8, 16...)

Challenge: Given the input number n. It should give me nested sublists of n layers with the power of two numbers for each level. ...
U13-Forward's user avatar
  • 2,001
15 votes
21 answers
747 views

CGAC2022 Day 16: Playing with bits, Part 2

Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. As soon as the Elves get bored with the last week's game, Bin comes up with a new game. The rules are similar, ...
Bubbler's user avatar
  • 76k
19 votes
26 answers
1k views

CGAC2022 Day 9: Playing with bits

Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. The Elves like playing number games. One day, Bin (a friend of Fen) suggests a new game: given a positive integer <...
Bubbler's user avatar
  • 76k
10 votes
10 answers
459 views

CGAC2022 Day 3: \$n\$-dimensional Chocolate Pyramid

Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. I've got an infinite supply of \$n\$-dimensional chocolate for some positive integer \$n\$. The shape of the ...
alephalpha's user avatar
12 votes
30 answers
2k views

Find the nth number where the digit sum equals the number of factors

(This is OEIS A057531.) Your task Given a positive integer, \$n\$, find the \$n\$th number where the digit sum equals the number of factors Explanation For example, let's take 22: Its factors are \$[1,...
The Thonnu's user avatar
24 votes
20 answers
2k views

"Prime" pyramid

The pyramid begins with the row 1 1. We'll call this row 1. For each subsequent row, start with the previous row and insert the current row number between every ...
chunes's user avatar
  • 24k
23 votes
29 answers
2k views

Power sequence differences

Your task Given two positive integers \$x\$ and \$d\$ (such that \$d<x\$), output the 5th term of the \$d\$th difference of the sequence \$n^x\$ Example Let's say we are given the inputs \$x=4\$ ...
The Thonnu's user avatar
19 votes
29 answers
2k views

Length of Binary as Base 10 [OEIS A242347]

Computers like binary. Humans like base 10. Assuming users are humans, why not find the best of both worlds? Your task is to find the first n terms in the sequence ...
pacman256's user avatar
  • 3,760
30 votes
17 answers
2k views

Looking back at all the things I said ...

The look-say sequence is a sequence of lists of numbers where each element is the previous element with run length encoding. Run length encoding is the process of grouping together like elements and ...
Wheat Wizard's user avatar
  • 98.5k
19 votes
10 answers
2k views

Enumerate the rationals

The cardinality of the set \$\mathbb Q\$ of rational numbers is known to be exactly the same as that of the set \$\mathbb Z\$ of integers. This means that it is possible to construct a bijection ...
att's user avatar
  • 20.4k
16 votes
15 answers
2k views

Generate the n'th Fermi-Dirac Prime

A Fermi-Dirac Prime is a prime power of the form \$p^{2^k}\$, where \$p\$ is prime and \$k \geq 0\$, or in other words, a prime to the power of an integer power of two. They are listed as integer ...
infinitezero's user avatar
  • 1,646
20 votes
7 answers
3k views

The smallest area of a convex grid polygon

I got an email from Hugo Pfoertner, an Editor-in-Chief at the On-Line Encyclopedia of Integer Sequences, with a terrific idea for a fastest-code challenge, which will also help verify or expand the ...
Peter Kagey's user avatar
  • 8,679
13 votes
22 answers
1k views

Even and Odd kinds

Let \$n\$ be some positive integer. We say that \$n\$ is of even kind if the prime factorisation of \$n\$ (counting duplicates) has an even number of integers. For example, \$6 = 2 \times 3\$ is of ...
caird coinheringaahin g's user avatar
6 votes
5 answers
898 views

What is the longest trampoline?

In this challenge we are going to consider lists of integers such that for every member \$x\$ at index \$i\$ then the indexes \$i+x\$ and \$i-x\$ have the value \$x+1\$ or are out of bounds for the ...
Wheat Wizard's user avatar
  • 98.5k
16 votes
12 answers
1k views

Triangular honeycomb numbers

From the infinite triangular array of positive integers, suppose we repeatedly select all numbers at Euclidean distance of \$\sqrt{3}\$, starting from 1: $$ \underline{1} \\ \;2\; \quad \;3\; \\ \;4\; ...
Bubbler's user avatar
  • 76k
24 votes
22 answers
2k views

Triangular polkadot numbers

From the infinite triangular array of positive integers, suppose we select every 2nd numbers on every 2nd row as shown below: $$ \underline{1} \\ \;2\; \quad \;3\; \\ \;\underline{4}\; \quad \;5\; \...
Bubbler's user avatar
  • 76k
12 votes
18 answers
603 views

Count the number of compositions of \$n\$ in which the greatest part is odd

A composition of an integer \$n\$ is a representation of \$n\$ as a sum of positive integers. For example the eight compositions of 4 are as follows: ...
user avatar
17 votes
38 answers
3k views

Calculating π using the Gregory Leibniz series until n terms

based off my previous challenge, this wikipedia article, and a Scratch project Your task: given i, calculate \$\pi\$ till i ...
SectorCorruptor's user avatar
21 votes
17 answers
2k views

Calculate Pi unto a point using the Nilakantha series

Your task: given a nonzero positive number i, calculate pi using the Nilakantha series unto i terms. The Nilakantha series is as ...
SectorCorruptor's user avatar
14 votes
10 answers
1k views

IMO Question Six with a difference

In 1988, the International Mathematical Olympiad (IMO) featured this as its final question, Question Six: Let \$a\$ and \$b\$ be positive integers such that \$ab + 1\$ divides \$a^2 + b^2\$. Show ...
Jonathan Allan's user avatar
-2 votes
3 answers
390 views

Find the GCD and LCM of a list of numbers [duplicate]

Note: most of the questions that are already in existence about this topic only deal with two numbers as inputs. This question deals with any number (>1) of inputs. GCD The GCD (greatest common ...
The Thonnu's user avatar
15 votes
14 answers
5k views

The "Fly straight, dammit" sequence

Background "Fly straight, dammit" (OEIS A133058) is a sequence of integers, which has these rules: \$a_0 = a_1 = 1\$ \$a_n = a_{n-1}+n+1\$ if \$gcd(a_{n-1}, n) = 1\$ Otherwise, \$a_n = \...
The Thonnu's user avatar
6 votes
14 answers
1k views

Number of ways to make an amount with coins

This is not a duplicate of Sum of combinations with repetition. This question considers 1+2 to be the same as 2+1. The other ...
The Thonnu's user avatar
12 votes
18 answers
1k views

Find the nth Mersenne Prime

A number is a Mersenne Prime if it is both prime and can be written in the form 2m-1, where m is a positive integer. For example: 7 is a Mersenne Prime because it is 23-1 11 is not a Mersenne Prime ...
The Thonnu's user avatar
12 votes
12 answers
352 views

Runs of Ones (What Fun!) [duplicate]

Suppose you have an array with some known set of values (e.g. a string of \$0\$ and \$1\$) and you want to get all the locations of \$1\$s. Instead of storing a list of all the indices, if the \$1\$s ...
97.100.97.109's user avatar
14 votes
7 answers
995 views

Exponential transform of an integer sequence

The exponential generating function (e.g.f.) of a sequence \$a_n\$ is defined as the formal power series \$f(x) = \sum_{n=0}^{\infty} \frac{a_n}{n!} x^n\$. When \$a_0 = 0\$, we can apply the ...
alephalpha's user avatar
19 votes
16 answers
2k views

Infinite quote escaping sequence

Related We start with the string a, and forever append to the string a comma followed by the string quote-escaped, where quote-escaping means doubling all quotes in ...
Command Master's user avatar
12 votes
16 answers
2k views

Squash it ... again!

If you place the positive integers together and read each set of two adjacent digits at the same time, you get: (A136414) ...
math scat's user avatar
  • 9,228
16 votes
14 answers
983 views

Number of binary partitions

We all know that any positive integer can be represented as the sum of powers of two. This is how binary representations work. However there's not just one way to do this. The canonical method, ...
Wheat Wizard's user avatar
  • 98.5k
18 votes
16 answers
2k views

Fibonacci polynomials

The Fibonacci polynomials are a polynomial sequence defined as: \$F_0(x) = 0\$ \$F_1(x) = 1\$ \$F_n(x) = x F_{n-1}(x) + F_{n-2}(x)\$ The first few Fibonacci polynomials are: \$F_0(x) = 0\$ \$F_1(x) ...
alephalpha's user avatar
17 votes
15 answers
1k 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 ...
emanresu A's user avatar
  • 37.8k
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 ...
emanresu A's user avatar
  • 37.8k
15 votes
13 answers
993 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 ...
pxeger's user avatar
  • 23.7k
18 votes
13 answers
2k views

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 ...
emanresu A's user avatar
  • 37.8k
10 votes
27 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 ...
Someone's user avatar
  • 1,580
6 votes
1 answer
670 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 ...
Romanp's user avatar
  • 1,357

1
2
3 4 5
19