Questions tagged [integer]
For challenges involving the manipulation of integers.
149 questions
37
votes
50
answers
4k
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 ...
90
votes
201
answers
12k
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 ...
72
votes
177
answers
13k
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:
...
71
votes
66
answers
7k
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: [1] ...
33
votes
60
answers
8k
views
Sort an Integer List
The Challenge
It's quite simple really, sort a list of numbers.
Details
You must sort a list of numbers in ascending order, without using any built-in sorting functions/libraries/etc (i.e. ...
17
votes
105
answers
9k
views
Turn an integer n into a list containing it n times [closed]
Given an integer n as input, return a list containing n, repeated n times. For example, the ...
25
votes
25
answers
2k
views
Mountain range numbers
Mountain range number
A number is a mountain range number if the inequalities satisfied by their consecutive digits alternate. In a way, looking at the number's digits should exhibit a ...
34
votes
56
answers
4k
views
Swap Two Values in a List
Introduction:
Although we have a lot of challenges where swapping two items in a list is a subtask, like Single swaps of an array; Swap to Sort an Array; \$n\$ swaps into a nop; etc., we don't have ...
24
votes
9
answers
1k
views
Spiral neighbourhoods
If we take the natural numbers and roll them up counter clock-wise into a spiral we end up with the following infinite spiral:
...
53
votes
43
answers
4k
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 \$\text{lcm}\$\$(A, B)\$ ...
45
votes
48
answers
5k
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 ...
43
votes
56
answers
10k
views
Is this a triangle?
Task
Write a function/program that, given three positive integers a, b and c, prints a ...
40
votes
75
answers
7k
views
Find the highest unique digit
Surprisingly we haven't had a simple "find the highest digit" challenge yet, but I think that's a little too trivial.
Given input of a non-negative integer, return the highest unique (ie not ...
38
votes
53
answers
4k
views
(RGS 1/5) Binary multiples [duplicate]
A binary multiple of a positive integer k is a positive integer n such that n is written ...
37
votes
41
answers
5k
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 ...