# Questions tagged [integer]

For challenges involving the manipulation of integers.

282 questions
Filter by
Sorted by
Tagged with
7k views

### Is this number an integer power of -2?

There are clever ways of determining whether a number is a power of 2. That's no longer an interesting problem, so let's determine whether a given integer is an integer power of -2. For example: <...
317 views

### Mapping between integer and pronounceable word

Purpose The idea is to provide the code necessary to map a 32-bit integer to/from a pronouncable word of 9 characters maximum. That could be useful, for example, to make a serial number easier to ...
979 views

### Integer-Digits of the Arithmetic-Tables

Challenge: Output the 'integer-digits' of one of the following six arithmetic-tables based on the input: - addition (+); - subtraction (...
3k views

### Pigeonhole Principle & Code Golf

The pigeonhole principle states that If N items are put into M boxes, with N > M, then at least one box must contain more than one item. For many, this principle has a special status compared to ...
76 views

### Storing an array of Integers to WOM [closed]

Very few, if any, programs or applications have utilised the proposed spec for WOM which was initially thought up in the early 1970s as a polar opposite to ROM, so your task is to take a dataset of n ...
645 views

### Sort and Re-apply Deltas of an Array

It seems that any Simple Modification of deltas using a consistent function can almost always be done some other shorter way, Dennis. Thus, the only solution I can imagine to make this harder, is to ...
4k 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: ...
453 views

### How much does this Integer score?

The Challenge Given an integer, calculate its score as described below. The score is calculated by raising each digit of the input Integer to the power n, where <...
455 views

### Compute the most efficient binary function

Today, we'll be computing the most efficient binary function. More specifically, we'll be computing the function which, when an expression is created from applying the function to the constant input 0 ...
5k views

### Oddly Even, Positively Negative

Given N, output the Nth term of this infinite sequence: -1 2 -2 1 -3 4 -4 3 -5 6 -6 5 -7 8 -8 7 -9 10 -10 9 -11 12 -12 11 ... etc. N may be 0-indexed or 1-...
1k views

### Fill in an increasing sequence with as many numbers as possible

A list of numbers is called monotonically increasing (or nondecreasing) is every element is greater than or equal to the element before it. For example, ...
3k views

### Solve an equation with (almost) any numbers you like

Given a string of the characters +=- where there is at least one =, insert positive integers between all the symbols and at the ...
6k views

### N-dimensional N^N array filled with N

In: Enough memory and a positive integer N Out: N-dimensional N^N array filled with N, where N^N means N terms of N-by-N-by-N-by... Examples: 1:  ...
2k views

### Bitflip-resistant composite numbers

Sometimes, when writing a program, you need to use a prime number for some reason or other (e.g. cryptography). I assume that sometimes, you need to use a composite number, too. Sometimes, at least ...
2k views

### Find Recursively Prime Primes

The Recursively Prime Primes is are sequence of primes such that p(1) = 2 p(n) = the p(n-1)th prime Here is an example of how one might calculate the 4th ...
2k views

### A sequence of sums of integers that aren't in the sequence

Background Consider a sequence defined as follows: The first element is 0; The second element is 4; From the third element onwards, its value can be calculated by: Taking the set of integers from 0 ...
986 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 ...
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....
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 ...
2k views

### Output the Euler Numbers

Given a non-negative integer $n ,$ output the $n^{\text{th}}$ Euler number (OEIS A122045). All odd-indexed Euler numbers are $0 .$ The even-indexed Euler numbers can be computed with the ...
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 ...
527 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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
3k 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 ...
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 ...
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 ...
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 ...
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 ...
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, ...
922 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 ...
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 ...
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, ...
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 ...
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: ...
802 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, ...
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 ...
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 ...
1k 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: ...
677 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 <...
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 ...
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 ...
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 ...
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 ...