Questions tagged [integer]

For challenges involving the manipulation of integers.

19
votes
12answers
985 views

Anagram Factors

On a recent episode of QI, the first 5 multiples of 142857 were described as anagrams of the original number. Of course, anyone with more than a passing knowledge of that number will know that those ...
35
votes
20answers
2k views

Sum the powers that be

A simple but hopefully not quite trivial challenge: Write a program or function that adds up the kth powers dividing a number n....
19
votes
8answers
3k views

Give me your tired, your poor, Your huddled masses yearning to breathe free

A bronze plaque in the pedestal of the Statue of Liberty displays the poem "The New Colossus" by Emma Lazarus, part of which reads: Give me your tired, your poor, Your huddled masses yearning to ...
27
votes
14answers
1k views

Output the Euler Numbers

Given a non-negative integer n, output the nth Euler number (OEIS A122045). All odd-indexed Euler numbers are 0. The even-...
26
votes
26answers
2k views

Digital Hardness of Integers

To find the digital hardness of an integer, take its binary representation, and count the number of times both a leading and trailing 1 can be removed until it ...
22
votes
4answers
520 views

What did I just play? Translate guitar fingerings to chords

Related: Music: what's in this chord?, Notes to Tablature, Generating guitar tabs?, Translate number pairs to guitar notes Given a guitar fingering, output the chord it represents. You can use ...
28
votes
11answers
1k views

2016 Time Capsule String: Climb The Integer Ladder

Using the 74 characters from the 2016 time capsule string H@~*^)$.`~+1A|Q)p~`\Z!IQ~e:O.~@``#|9@)Tf\eT`=(!``|`~!y!`) Q~$x.4|m4~~&!L{% write N code snippets ...
35
votes
34answers
3k views

Is it a Mersenne Prime?

A number is a Mersenne Prime if it is both prime and can be written in the form 2n-1, where n is a positive integer. Your task is to, given any positive integer, determine whether or not it is a ...
23
votes
16answers
1k views

Golf a Numerical Growing Braid

Braid Description In this braid, when a strand crosses over the top of another strand it adds the other strand's value to itself and all other strand values pass through. The braid has three strands ...
36
votes
14answers
1k views

An Array of Challenges #2: Separate a Nested Array

Note: This is #2 in a series of array-manipulation challenges. For the previous challenge, click here. Separating Nested Lists To separate values in a nested list, flatten it, and then wrap each ...
66
votes
141answers
7k views

Output the sign

Given a number N, output the sign of N: If N is positive, output 1 If N is negative, output -1 If N is 0, output 0 N will be an integer within the representable range of integers in your chosen ...
44
votes
50answers
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 ...
30
votes
38answers
2k views

Find the sum of all numbers below n that are a multiple of some set of numbers

Almost equivalent to Project Euler's first question: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find ...
41
votes
39answers
2k views

An Array of Challenges #1: Alternating Arrays

Alternating Arrays An alternating array is a list of any length in which two (not necessarily different) values are alternating. That is to say, all even-indexed items are equal, and all odd-indexed ...
34
votes
14answers
1k views

Generate n-ary numbers

A secondary number is a positive integer whose prime factors (without multiplicity) are all less than or equal to its square root. 4 is a secondary number, because ...
102
votes
32answers
11k views

What are the five most powerful characters in your language?

Choose any five characters your language supports. There are 5! = 5×4×3×2×1 = 120 ways these can be arranged into a 5-character string that contains each character once; 120 ...
18
votes
16answers
1k views

Plus and Times, Ones and Nines

Implement this recurrence relation as a function or program that inputs and outputs a non-negative integer: F(0) = 0 F(N) = the smallest integer greater than F(N-1) such that the sum and/or product ...
23
votes
25answers
2k views

Reverse Deltas of an Array

Reverse Deltas of an Array A continuation of Inverse Deltas of an Array Your task is to take an array of signed 32 bit integers, recompile it with its deltas reversed. Example The List, ...
20
votes
7answers
920 views

Numpad Word Search

Given an integer from 1 to 999 inclusive, output a truthy value if it appears horizontally, vertically, or diagonally, either forwards or backwards, anywhere in the 3x3 square of digits 1-9 on a ...
36
votes
24answers
3k views

Complex Binary Numbers

Let's create a simple, surjective mapping from positive integers to Gaussian integers, which are complex numbers where the real and imaginary parts are integers. Given a positive integer, for example ...
29
votes
43answers
2k views

The Squaring Sequence

Each term in the squaring sequence, xn, is created by taking xn-1, squaring it, and removing all but the first four digits. The sequence always begins with x1 = 1111. Squaring this yields 1234321, ...
19
votes
7answers
1k views

Alphabetize Integers

Alphabetize Integers For a given set of numbers, put them in alphabetical order when they are spelled out (i.e. 1: one, 2: two, 90: ninety, 19: nineteen). Your code should work for the range ...
44
votes
37answers
3k views

Increment an Array

Given a nonempty array of positive integers, "increment" it once as follows: If all the array elements are equal, append a 1 to the end of the array. For example: ...
15
votes
9answers
800 views

All the Xenodromes

Introduction A xenodrome in base n is an integer where all of its digits in base n are different. Here are some OEIS sequences of xenodromes. For example, in base 16, ...
17
votes
24answers
1k views

Inverse Deltas of an Array

Inverse Deltas of an Array Your task is to, given an array of signed 32 bit integers, recompile it with its inverse deltas. For example, the list 1 3 4 2 8 ...
33
votes
31answers
3k views

Let's decrease the monotony

...but hey, no need to be strict. Given a non-empty array of strictly positive integers, determine if it is: Monotone strictly decreasing. This means that each entry is strictly less than the ...
15
votes
7answers
777 views

Find the Emirps!

An emirp is a non-palindromic prime which, when reversed, is also prime. The list of base 10 emirps can be found on OEIS. The first six are: ...
14
votes
4answers
669 views

Binary Convolution

A binary convolution is described by a number M, and is applied to a number N. For each bit in the binary representation of <...
18
votes
24answers
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 ...
14
votes
19answers
2k views

Produce Dürer's magic square

The challenge Output an array or string representation of Dürer's famous magic square: that is, 16 3 2 13 5 10 11 8 9 6 7 12 4 15 14 1 Some properties ...
28
votes
17answers
3k views

Draw an ASCII-O'-Lantern for Halloween

Halloween is almost here, the holiday after which most people need to wean themselves off a hollow diet of sugar. Write a program that takes in a positive integer. If the integer is less than 31 (1 ...
31
votes
42answers
2k views

Least Common Multiple

The least common multiple of a set of positive integers A is the smallest postive integer B such that, for each ...
48
votes
120answers
7k views

Print all integers

Write a program or function which will provably print all integers exactly once given infinite time and memory. Possible outputs could be: ...
45
votes
20answers
4k views

Greater than less than greater than something fishy

Given a length N string of less-than and greater-than signs (<, >), insert the integers 0 through N at the start and end ...
35
votes
71answers
4k views

As Easy as One-Two-Three

Write a program or function that takes in a positive integer. You can assume the input is valid and may take it as a string. If the number is any of ...
17
votes
15answers
2k views

Write a program that outputs the number of times it has been run [duplicate]

In a programming language of your choice, write a full program that, when run, prints a positive integer N and then modifies its own source file such that the next time it is run it will print N+1. ...
23
votes
33answers
2k views

Where are Champernowne's zeroes?

Consider the infinite string of all nonnegative decimal integers concatenated together in order (akin to Champernowne's constant): ...
23
votes
39answers
4k views

Smallest palindrome divisible by the input

Given a positive integer N, output the smallest positive integer such that this number is a palindrome (i.e. is its own reverse) and is divisible by ...
15
votes
20answers
1k views

Smallest positive number whose y-th power is divisible by x

Task Given integers x and y which are both at least 2, find the smallest positive number ...
5
votes
8answers
528 views

Smallest positive integer not yet appeared so that the sum of the first n elements is divisible by n

Task Given positive integer n, output a(n) where a is the sequence defined below: ...
12
votes
5answers
566 views

A047841: Autobiographical numbers

Definition Here is the process to describe a number: For each number from 0 to 9 that is present in the number: Write down the ...
17
votes
9answers
2k views

Integer goes back and forth through time

Input: An integer. Output: First convert the integer to it's equivalent Roman Numeral. Then convert each capital letter of that Roman Numeral to their ASCII/UNICODE decimal value. And output the ...
2
votes
5answers
236 views

“Break” a number [closed]

Origins tl;dw (too lazy, didn't write): thought of it right before I fell asleep Challenge Breaking a number is defined as the following steps: Take a number or a parseable data type as input in ...
2
votes
5answers
2k views

The fastest square root calculator

Write a program which outputs the square root of a given number in the shortest time possible. Rules It may not use any builtins or powering with non-integers. Input format as a function argument ...
21
votes
33answers
2k views

Calculate the sum of ILD

Input: An integer Output: Sum of the input itself + the length of the input + each individual digit of the input. nr + nr-length + {sum of digits} = output ...
8
votes
8answers
562 views

Excludivisible numbers

Given an integer N, output the Nth positive number K with the following property in decimal ...
32
votes
4answers
4k views

The happy Ender problem

The happy ending problem (actually a theorem) states that Any set of five points in the plane in general position has a subset of four points that form the vertices of a convex quadrilateral. The ...
15
votes
33answers
2k views

Separate alphabets and numbers

A paragraph of text has numbers and alphabetic letters mixed. Your task is to separate the numbers to the left side and the alphabetic letters to the right side in the same order of each line. Rules:...
9
votes
29answers
3k views

The Nine Pattern

Introduction I stumbled across this (useless) pattern the other day while I was watching TV. I named it "the 9 pattern" because the first number to use it was 9. The gist of it is, you enter a number ...
21
votes
23answers
1k views

Divisor reduction

A divisor of a number n is any number that evenly divides n, including 1 and n itself. The number of divisors d(n) is how many divisors a number has. Here's d(n) for the first couple n: ...