# Questions tagged [integer]

For challenges involving the manipulation of integers.

282 questions
Filter by
Sorted by
Tagged with
2k views

### Find the largest number of distinct integers that sum to n

The Task Given an input positive integer n (from 1 to your language's limit, inclusively), return or output the maximum number of distinct positive integers that ...
2k views

### Am I a 'Redivosite' Number?

Redivosite is a portmanteau word invented for the sole purpose of this challenge. It's a mix of Reduction, Division and Composite. Definition Given an integer N > 6: If N is prime, N is not a ...
1k views

### Compute the Optimal Square Matrix

The optimal matrix (for the rather narrow scope of this challenge) is obtained by "zipping" the elements from the corresponding rows and columns of a square matrix and getting the maximum of each pair....
400 views

### Balanced ternary logic

Balanced ternary logic Ternary is normally another name for base 3, that is to say, each digit is 0, 1, or ...
2k views

### Single swaps of an array

Inspired by Taken from a question at Stack Overflow. The challenge Given an integer n>1, output all arrays that can be obtained by swapping exactly two entries ...
2k views

### Output the hours at 90 degrees

Today while playing with my kids I noticed that an apparently simple toy in the park hid a challenge. The wheel has a triangle that points to a number, but also has three circles that point to the ...
4k views

### How small can it get?

Starting with a positive integer N, find the smallest integer N' which can be computed by repeatedly dividing N by one of its digits (in base-10). Each selected digit must be a divisor of N greater ...
335 views

### Is it a Satisfying Number?

inspired by this chat conversation A satisfying number is a number whose decimal representation is of the form abx, with the following properties: ...
562 views

### N-bit Variation on Subset-Sum

For another challenge I am writing, I need to verify that test cases are solveable with bounded integers. Specifically, I need to verify the following, for a non-empty array of integers ...
2k views

### Frequency Distribution of Mixed Dice Rolls

A follow-up to this challenge Given a set of mixed dice, output the frequency distribution of rolling all of them and summing the rolled numbers on each die. For example, consider ...
1k views

### The sequence of self-contained numbers

Let's define a self-contained number as a positive integer, whose digits appear in runs of length equal to themselves only. In other words, any decimal digit d (excluding 0) occurs only in runs of ...
2k views

### Find a Fixed Point

Given an integer x1 and some black box function f: ℤ → ℤ find a fixed point of f in the ...
1k views

### 2 factors factorization

Given a natural number n write a program or function to get a list of all the possible two factors multiplications that can be used to achieve ...
6k views

### Find the smallest positive integer which ends in n, is divisible by n and whose digits sum to n

It's all in the title... Take as input a positive integer n>=12 and... do what the title says. Yes, this is on OEIS A187924. Some test cases ...
1k views

### Minimal sparse rulers

A standard ruler of length n has distance marks at positions 0, 1, ..., n (in whichever units). A sparse ruler has a subset of those marks. A ruler can measure the distance k if it has marks at ...
3k views

### Swap the Endianness

As most of you probably know, (byte-addressable) hardware memories can be divided into two categories - little-endian and big-endian. In little-endian memories the bytes are numbered starting with 0 ...
1k views

### Reconstruct an arithmetic sequence

Given a finite arithmetic sequence of positive integers with some terms removed from the middle, reconstruct the whole sequence. The task Consider an arithmetic sequence: a list of positive integers ...
4k views

### Reduce a number by its largest digit

Task: Given an integer number in decimal number system, reduce it to a single decimal digit as follows: Convert the number to a list of decimal digits. Find the largest digit, D Remove D from the ...
4k views

### Is it a whole number?

A number is whole if it is a non-negative integer with no decimal part. So 0 and 8 and ...
6k views

### Is my barcode valid?

An EAN-8 barcode includes 7 digits of information and an 8th checksum digit. The checksum is calculated by multiplying the digits by 3 and 1 alternately, adding the results, and subtracting from the ...
3k views

### Take a byte out of it!

Your task is to, given an unsigned integer n, find the largest number which can be created by removing a single byte (8 consecutive bits) of data. Example Given ...
1k views

### Seqindignot sequence

Title is made up, from 'Sequence Index Digit Not'. Challenge: Given an integer n which is >= 0, output the ...
3k views

### Take one to make one

Challenge Given a list of positive integers, find if there exists a permutation where taking up to one bit from each of the integers, a binary number consisting of all ...
3k views

### Basic sort, with annoying bug

Your input is a list/sequence/vector/array of 5-255 positive integers, not necessarily unique. You may assume whatever input format is most suitable, and that each integer (as well as the quantity of ...
3k views

### Find the unique twins

You will be given two Arrays / Lists / Vectors of non-negative integers A and B. Your task is to output the highest integer N that appears in both A and B, and is also unique in both A and B. You ...
215 views

### Solve the equation a*x == b with Int32 arithmetics [duplicate]

In this thread we use 32-bit signed integers (assuming the usual two's complement). For simplicity I shall call this type Int32. The range is from -2147483648 ...
4k views

### Smallest Zeroless Base

Given a positive integer n, output the smallest base b >= 2 where the representation of n ...
2k views

### Largest Prime Exponents

Given an integer n >= 2, output the largest exponent in its prime factorization. This is OEIS sequence A051903. Example Let ...
786 views

### Alternested numbers

Consider the array of positive integers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ... Then, concatenate them: ...
871 views

### Create a universal integer sequence

Definition Let's call an (infinite) integer sequence universal if it contains every finite integer sequence as a contiguous subsequence. In other words, the integer sequence (a1, a2, …) is universal ...
900 views

### Nth Ngonal Numbers

Most of us are probably familiar with the concept of triangular and square numbers. However, there are also pentagonal numbers, hexagonal numbers, septagonal numbers, octagonal numbers, etc. The Nth ...
165 views

### Multi-Base Primes [closed]

For the purpose of this challenge, a multi-base prime is a prime which, when written in base 10, is prime in one or more bases smaller than 10 and larger than 1 as well. All single-digit primes are ...
2k views

### A train crosses a labeled bridge

Consider a bridge of length B formed by tiles labeled with the digits of the positive integers concatenated. For example, if B was 41, then it would look like this: -----------------------------------...
1k views

### Least integer as a product of given factors

There have been a lot of prime-/prime factorization-related challenges recently, so I thought it might be interesting to go the other way. Given: a positive integer ...
1k views

### Primes in the prime factorisation

I saw another prime challenge coming by in PPCG, and I do love me some primes. Then I misread the introductory text, and wondered what the creative brains here had come up with. It turns out the ...
2k views

### How many unique primes?

One way to represent a natural number is by multiplying exponents of prime numbers. For example, 6 can be represented by 2^1*3^1, and 50 can be represented by 2^1*5^2 (where ^ indicates exponention). ...
1k views

### Prime Powers of Primes

For the purpose of this challenge, a Prime Power of a Prime (PPP) is defined as a number that can be defined as a prime number to the power of a prime number. For example, 9 is a PPP because it can ...
438 views

### A Slashy Dashy Spiral [duplicate]

Given a positive integer N, output the innermost N×N square of an ASCII art spiral made of -|/\ that spirals clockwise inward. The ...
2k views

### Back to the Basics of Math

Introduction: We all know these three basic arithmetic math tables I assume. ...
2k views

### Frequency Distribution of Multiple Dice Rolls

Given two positive integers a and b, output the frequency distribution of rolling a b-sided ...
3k views

### Illustrate the Least Common Multiple

Given two positive integers, A and B, illustrate their least common multiple by outputting two lines of dashes (-) with length LCM(A, B) after replacing every Ath ...
2k views

### Dizzy integer enumeration

Your challenge today is to output a given term of a sequence enumerating all of the integers. The sequence is as follows: If we have a 0-indexed function generating the sequence ...
1k views

### Pandigital Doubling

Inspired by this CMC Given a positive integer greater than 0, perform the following operation on it: If all ten single digits (1234567890) are in the number at ...
2k views

### Sort the points by linear distance in a 3D space

Specs You have a cubic 3D space x,y,z of size S integer units, such as 0 <= x,y,z <= S...
1k views

### Sum the deltas of my matrix

Background The deltas of an array of integers is the array formed by getting the differences of consecutive elements. For example, [1, 2, 4, 7, 3, 9, 6] has the ...
2k views

### Find the sum of the divisors of N

Write a program that displays on the screen the sum of the divisors of a number (1 ≤ N ≤ 100) entered by the user in the range of 1 to N. This is OEIS A000203. Examples: Input: 7 ...
2k views

### Help! My calculator malfunctions!

Introduction My calculator is behaving weird. Sometimes when I type in an 8 it displays a 2. And sometimes when I type in a <...
673 views

### Sum the rows of the concatenated triangle

Consider the following triangle. 1 23 456 7891 01112 131415 1617181 92021222 324252627 2829303132 33343536373 839404142434 4454647484950 51525354555657 585960616263646 5666768697071727 ...