Questions tagged [sequence]

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

Filter by
Sorted by
Tagged with
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 ...
C. K. Young's user avatar
  • 4,947
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 ...
caird coinheringaahin g's user avatar
91 votes
109 answers
27k views

4, 8, 15, 16, 23, 42 [closed]

4, 8, 15, 16, 23, 42 Write a program that outputs this sequence of numbers infinitely. However, The Numbers must not appear in your source code anywhere. The following is not a valid Java program to ...
Radiodef's user avatar
  • 2,416
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 ...
Doorknob's user avatar
  • 71.5k
84 votes
55 answers
12k views

Can you outgolf me? (Cops section)

Cops section The robbers section can be found here. Thanks to FryAmTheEggman, Peter Taylor, Nathan Merrill, xnor, Dennis, Laikoni and Mego for their contributions. Challenge Your task is to write 2 ...
Adnan's user avatar
  • 44.4k
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 ...
user41805's user avatar
  • 13.1k
78 votes
19 answers
4k views

Golf Dennis a thermometer

Dennis puts in a huge amount of effort for this community, including as moderator, language designer, and provider of TIO. Unfortunately, his four-year-old daughter has caught a cold, so let us all ...
Adám's user avatar
  • 30.2k
75 votes
13 answers
4k views

Generate Dennis Numbers

This challenge is a tribute to PPCG user Dennis for winning the robbers' part of The Programming Language Quiz. Looking at Dennis' PPCG profile page we can see some pretty impressive stuff: He ...
Calvin's Hobbies's user avatar
72 votes
28 answers
7k views

Calculate Phi (not Pi)

No, I don't mean \$\phi = 1.618...\$ and \$π = 3.14159...\$. I mean the functions. \$\phi(x)\$ is the number of integers less than or equal to \$x\$ that are relatively prime to \$x\$. \$π(x)\$ is ...
El'endia Starman's user avatar
69 votes
47 answers
9k views

Compute the Kolakoski sequence

This is a repost of an old challenge, in order to adjust the I/O requirements to our recent standards. This is done in an effort to allow more languages to participate in a challenge about this ...
Martin Ender's user avatar
68 votes
27 answers
15k views

xkcd-Style Page Numbering

Randall Munroe's book "xkcd, volume 0" uses a rather odd number system for the page numbers. The first few page numbers are ...
Martin Ender's user avatar
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 ...
Clashsoft's user avatar
  • 993
59 votes
152 answers
6k views

Evolution of OEIS

In this challenge, the goal is to recreate the On-Line Encyclopedia of Integer Sequences one sequence at a time. Similar to the Evolution of Hello World, each answer depends on a previous answer. ...
PhiNotPi's user avatar
  • 29.1k
59 votes
18 answers
7k views

Count like Chuck Norris

As is well known, Chuck Norris counted to infinity. Twice Besides, Chuck Norris can count to infinity backwards. Also, although perhaps less known, Chuck Norris can speak a little Spanish in ...
Luis Mendo's user avatar
  • 104k
58 votes
70 answers
11k views

Am I a Fibonacci Number?

Your Task: Write a program or function to check if a number that is inputted is a Fibonacci number. A Fibonacci number is a number contained in the Fibonacci sequence. The Fibonacci Sequence is ...
Gryphon's user avatar
  • 7,235
57 votes
35 answers
7k views

Superstitious hotel elevator

Description Here's a very superstitious hotel elevator in Shanghai:                 It avoids the number 13, because ...
Lynn's user avatar
  • 68.7k
55 votes
22 answers
3k views

Dennis numbers 2.0

PPCG user and elected mod, @Dennis just became the second ever user to earn over 100k rep! This is a totally original idea, that I did not get from anybody else, but let's make a challenge based off ...
DJMcMayhem's user avatar
  • 59.2k
53 votes
11 answers
3k views

Surrounded Countries

Countries own a series of territories on a 1D world. Each country is uniquely identified by a number. Ownership of the territories can be represented by a list as follows: ...
Sisyphus's user avatar
  • 14.8k
51 votes
18 answers
9k views

The prime ant 🐜

The "prime ant" is an obstinate animal that navigates the integers and divides them until there are only primes left! Initially, we have an infinite array A containing all the integers >= 2 : ...
Arnaud's user avatar
  • 8,513
50 votes
13 answers
5k views

5, 2, 16, 3580, What comes next?

Consider the positive integer powers of five in decimal. Here are the first 25, right aligned: ...
Calvin's Hobbies's user avatar
49 votes
52 answers
11k views

Patience, young "Padovan"

Everyone knows the Fibonacci sequence: You take a square, attach an equal square to it, then repeatedly attach a square whose side length is equal to the largest side length of the resulting rectangle....
absoluteAquarian's user avatar
49 votes
71 answers
7k 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: ...
DJMcMayhem's user avatar
  • 59.2k
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 ...
Arnaud's user avatar
  • 8,513
49 votes
14 answers
4k views

Fissile Numbers

I found this sequence while working on Evolution of OEIS, but never got around to posting it as an answer. After writing a reference implementation in Mathematica, I thought this is a fun exercise to ...
Martin Ender's user avatar
48 votes
111 answers
7k views

Concatenating n with n + 1

Introduction OEIS sequence A127421 is the sequence of numbers whose decimal expansion is a concatenation of 2 consecutive increasing non-negative numbers. Put simply, every number in the sequence is ...
Amphibological's user avatar
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 ...
182764125216's user avatar
48 votes
16 answers
6k views

A naturally occurring prime generator

There are quite a large number of prime generating functions. Pretty much all of them are constructed and are based on the sieve of Eratosthenes, the Möbius function or the Wilson's theorem and are ...
Jakube's user avatar
  • 21.9k
48 votes
20 answers
5k views

The Holy Numbers

In many fonts (specifically in the Consolas font), 5 out of the 10 decimal digits have "holes" in them. We will call these holy digits: 46890 The 5 ...
user avatar
47 votes
39 answers
3k views

Last odd digit of power of 2

Task Given \$n\$, output position of the last odd digit in the decimal representation of \$2^n\$ (counting from the end). Rules There are no odd digits for \$n=1,2,3,6,11\$ \$(2, 4, 8, 64, 2048)\$ - ...
pajonk's user avatar
  • 16k
46 votes
57 answers
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 ...
devRicher's user avatar
  • 1,659
46 votes
73 answers
4k views

Can this number be written in (3^x) - 1 format?

Challenge: Create a program that accepts a positive integer and checks if it can be written in the form of (3^x)-1, where X is another positive integer. If it can, output X If it can't, output -1 ...
Offtkp's user avatar
  • 3,062
46 votes
50 answers
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 ...
Conor O'Brien's user avatar
46 votes
20 answers
5k views

Shotgun Numbers

The Shotgun numbers are a sequence with a rather simple definition but some interesting structure. Start with the natural numbers: ...
Martin Ender's user avatar
45 votes
86 answers
8k views

Print a bunch of uninteresting numbers!

An uninteresting number (which I totally didn't make up only for this challenge) is created like this: Take a positive integer N Create a new number O by adding the digits of N at the end of N ...
Seims's user avatar
  • 669
45 votes
44 answers
13k views

Fibonacci reversed!

Introduction We all know and love our Fibonacci sequence and have seen a myriad of challenge on it here already. However, we're still lacking a very simple case which this answer is going to provide: ...
SEJPM's user avatar
  • 3,393
45 votes
22 answers
8k views

The prime frog 🐸

The "prime frog" is a strange animal that jumps between integers, until it arrives on 3 or 19... Your program should accept an integer n as input and output the ...
Arnaud's user avatar
  • 8,513
44 votes
69 answers
4k views

Fibonacci-orial

Definition Fibonacci sequence F(n), on the positive integers, are defined as such: ...
Leaky Nun's user avatar
  • 49.7k
44 votes
32 answers
3k views

Polyglot Anagrams Cops' Thread

This challenge has two threads. This is the cops' thread. The robbers' thread is located here. Your challenge is to choose an OEIS sequence and write two full programs in two different languages that ...
Wheat Wizard's user avatar
  • 98.7k
43 votes
69 answers
5k views

Consecutive 1-Bits are Incremented

Given a pattern (string or array format) of Bits : [0,1,1,1,0,1,1,0,0,0,1,1,1,1,1,1] The tasks is to replace any number of consecutive 1-Bits with an ascending ...
Luis felipe De jesus Munoz's user avatar
43 votes
57 answers
8k views

Catalan Numbers

The Catalan numbers (OEIS) are a sequence of natural numbers often appearing in combinatorics. The nth Catalan number is the number of Dyck words (balanced strings of parenthesis or brackets such as <...
a spaghetto's user avatar
  • 11.2k
43 votes
52 answers
7k views

Can you outgolf me? (Robbers section)

Robbers section The cops section can be found here. Challenge Your task is to outgolf the submissions of the cops in the same language and the same version (for example, Python 3.5 ≠ Python 3.4, so ...
Adnan's user avatar
  • 44.4k
43 votes
17 answers
2k views

Generate the Temple Skyline Sequence

Consider the following process: Take some non-negative integer N. e.g. N = 571 Express it in binary with no leading zeroes. (Zero itself is the only exception, ...
Calvin's Hobbies's user avatar
42 votes
81 answers
4k views

Sylvester's sequence

Sylvester's sequence, OEIS A000058, is an integer sequence defined as follows: Each member is the product of all previous members plus one. The first member of the sequence is 2. Task Create a ...
Wheat Wizard's user avatar
  • 98.7k
42 votes
33 answers
3k views

Goodness Giza Golf!

A "Giza number", also colloquially known as a Timmy Number is any number where the digits represent a pyramid (A134810). For example, "12321" is a giza number because it can be visualized like this: <...
DJMcMayhem's user avatar
  • 59.2k
42 votes
30 answers
4k views

Cops: The Hidden OEIS Substring

This is a Cops and Robbers challenge. This is the cop's thread. The robber's thread is here. As a cop, you must pick any sequence from the OEIS, and write a program p that prints the first integer ...
DJMcMayhem's user avatar
  • 59.2k
41 votes
91 answers
5k views

Output the missing integer

You will be given a string. It will contain 9 unique integers from 0-9. You must return the missing integer. The string will look like this: ...
Josh's user avatar
  • 1,111
41 votes
12 answers
3k views

Polyglot the OEIS! [duplicate]

Note: This challenge has been moved to Polyglot the (non constant) OEIS! to avoid closure. Introduction We all know and love the on-line encyclopedia of integer sequences (OEIS). So what if we made ...
SEJPM's user avatar
  • 3,393
41 votes
32 answers
4k views

Compute the Digit Difference Sum of a Number

Consider taking some non-negative integer such as 8675309 and computing the absolute values of the differences between all the pairs of neighboring digits. For \$8675309\$ we get \$|8-6| = 2\$, \$|6-7|...
Calvin's Hobbies's user avatar
41 votes
31 answers
3k views

Print a booklet

Reading a book is easy, but printing a book can be a bit tricky. When printing a booklet, the printer needs to have the pages arranged in a certain manner in order to be read from left to right. The ...
tisaconundrum's user avatar
41 votes
14 answers
5k views

Incrementing Gray Codes

Introduction A Gray Code is an alternative to binary representation in which a number is incremented by toggling only one bit, rather than a variable amount of bits. Here are some gray codes along ...
Patrick Roberts's user avatar

1
2 3 4 5
19