Questions tagged [sequence]

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

Filter by
Sorted by
Tagged with
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. ...
87 votes
137 answers
13k views

Collatz Conjecture (OEIS A006577)

This is the Collatz Conjecture (OEIS A006577): Start with an integer n > 1. Repeat the following steps: If n is even, divide it by 2. If n is odd, multiply it by 3 and add 1. It is proven that ...
19 votes
15 answers
2k views
+200

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 ...
11 votes
4 answers
1k 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 ...
39 votes
128 answers
5k 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 ...
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 ...
27 votes
22 answers
8k views

1, 2, 4, 8, 16, ... 33?

Challenge Write a function/program that outputs either the n'th element, or the first n elements, in the well known number ...
23 votes
36 answers
2k views

Output "Fit" numbers

"Fit Numbers" Sam has a "brilliant" idea for compression! Can you help? Here is a rundown of Sam's compression scheme. First take in a base 10 representation of any natural number strictly smaller ...
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 ...
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 ...
26 votes
44 answers
3k views

X Steps Forward, 1 Step Back

Here the first 100 numbers of an easy sequence: ...
150 votes
335 answers
44k 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 ...
60 votes
268 answers
17k 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 ...
23 votes
11 answers
3k views

Highly composite numbers

A highly composite number is a positive integer that has more divisors than any smaller positive integer has. This is OEIS sequence A002182. Its first 20 terms are ...
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 ...
32 votes
31 answers
3k views

Digital Sum Fibonacci

We are all familiar with the Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765 However, instead of, <...
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 ...
49 votes
54 answers
5k views

Bit run rundown

Given an integer n > 0, output the length of the longest contiguous sequence of 0 or 1 in ...
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 ...
2 votes
3 answers
188 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 ...
83 votes
46 answers
11k views

Fibonacci + Fizz Buzz = Fibo Nacci!

Fibonacci + FizzBuzz = Fibo Nacci! Your challenge is to create a Fibo Nacci program! A Fibo Nacci program outputs the first 100 Fibonacci numbers (starting from 1). If the Fibonacci number is ...
13 votes
3 answers
445 views

A Lazy Bag of Bread

I work at a bakery that serves Wheat, Rye, Barley, Grain, and French bread, but the baker's a little weird - he stacks the loaves in random order, and sometimes just leaves some shelves at the end ...
-4 votes
6 answers
2k views

Output first \$n\$ digits of \$\pi^{1/\pi}\$

This challenge is to produce the shortest code for the constant \$\pi^{1/\pi}\$. Your code must output the first \$n\$ consecutive digits of \$\pi^{1/\pi}\$, where \$n\$ is given in the input. ...
26 votes
27 answers
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}|\$ ...
19 votes
21 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 ...
48 votes
35 answers
9k views

Nth term of Van Eck Sequence

Output the Nth term of the Van Eck Sequence. Van Eck Sequence is defined as: Starts with 0. If the last term is the first occurrence of that term the next term is 0. If the last term has occurred ...
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 ...
18 votes
24 answers
970 views

Repeated Consecutive Digital Product Sum Convergence

Given a positive integer n (Example: n=1234444999) Separate into consecutive digit runs: ...
33 votes
34 answers
3k views

Say What You See

The "Look and say" or "Say what you see" sequence is a series of numbers where each describes the last. ...
36 votes
56 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 ...
24 votes
32 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 ...
16 votes
48 answers
2k views

Alternating Sign Sequence

Introduction The sign of a number is either a +, or a - for every non-zero integer. Zero itself is signless (...
26 votes
31 answers
3k views

Different Way Forward

Given a list of integers produce a Forward Difference at a specified order/depth. For the list of integers: (10, 18, -12, 4, 8, -3, -5, 67, 9, 14) The Forward ...
110 votes
407 answers
20k 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 ...
19 votes
31 answers
2k views

Binary Countdown Length

inspired by Count down from infinity Given a non-negative integer N, output the number of repetitions of the following steps it takes to reach 0: Convert ...
1 vote
8 answers
288 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 = ...
38 votes
144 answers
8k views

Count up folks!

Introduction It may sound strange, but we haven't got ONE challenge for counting from 1 to n, inclusive. This is not the same ...
5 votes
5 answers
648 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{...
26 votes
24 answers
6k views

Can even numbers become prime?

The Sequence Everyone knows the only even prime number is 2. Ho-hum. But, there are certain even numbers n where, when ...
13 votes
14 answers
605 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 ...
26 votes
14 answers
5k views

Hamming numbers

Hamming numbers are numbers which evenly divide a power of 60. Equivalently, their prime factors are all \$ \le 5 \$. Given a positive integer, print that many Hamming numbers, in order. Rules: Input ...
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 ...
29 votes
30 answers
4k views

Inverse Colombian Function

Let's define a sequence: The n digit summing sequence (n-DSS) is a sequence that starts with n. If the last number was k, then the next number is k + digit-sum(k). Here are the first few n-DSS: ...
18 votes
16 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 ...
26 votes
73 answers
6k views

Display numbers lacking 2's

Display numbers from one to one-hundred (in increasing order), but number 2 shouldn’t appear anywhere in the sequence. So, for example, the numbers two (2) or ...
22 votes
17 answers
1k views

All your base palindromic belong to us

Generate the sequence number of bases in which n is a palindrome (OEIS A126071). Specifically, the sequence is defined as follows: given a number ...
33 votes
27 answers
2k views

Stackable sequences

You deal cards labeled 0 to 9 from a deck one a time, forming stacks that start at 0 and count up by 1. When you deal a 0, you place it on the table to start a new stack. When you deal any other ...
1 vote
0 answers
147 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 ...
19 votes
9 answers
977 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. ...
32 votes
32 answers
5k views

Lockers vs. Crackers: The Five-Element Sequence

The Challenge A simple "spy versus spy" challenge. Write a program with the following specifications: The program may be written in any language but must not exceed 512 characters (as represented ...

1
2 3 4 5
19