Questions tagged [integer]
For challenges involving the manipulation of integers.
459 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
13
votes
11
answers
368
views
Rebase Until Inert
This is a sequel to Numbers Interpreted in Smallest Valid Base.
Let us define the operation of rebasing a number as writing out its digits in decimal form, then interpreting them in the smallest base <...
17
votes
23
answers
1k
views
Numbers Interpreted in Smallest Valid Base
Let us define the operation of rebasing a number as writing out its digits in decimal form, then interpreting them in the smallest base N possible (...
12
votes
12
answers
593
views
Recursive cumulative sum [duplicate]
Challenge:
Given inputs \$i\$ and \$n\,ドル calculate \$R_i(n)\$ where:
$$R_0(n)=n \\
R_i(n)=\sum_{j=0}^nR_{i-1}(j)$$
Note that \$R_1\$ is triangular function, and \$R_2\$ is tetrahedral function.
This ...
10
votes
2
answers
343
views
Check if a number is a power with its program value being a power
Task:
Your task is make a program to check if there exists integers \$a \ge 2, b \ge 2\$ such that \$a^b=i\$ where \$i\$ is the input integer at least 2.
The catch is that your program must return a ...
11
votes
11
answers
704
views
Find a linear function such that if f(0), f(1), f(2), ⋯ are indices of the elements of the list, the sum must equal to its slope
Challenge:
Find integers \$a\$ and \$b\$ defining linear function \$f(x) = ax + b\$ with \$a > 0, b \ge 0\$ such that the sum of the elements of the input list \$l\$ located at the values of the ...
13
votes
9
answers
2k
views
Pennies to Dollars
Over on Puzzling a couple years ago, Hermant Agarwal proposed the following question:
In a certain country the following coins are in circulation: 1 cent, 2 cents, 5 cents, 10 cents, 20 cents, 50 ...
2
votes
13
answers
643
views
List of prime distances
Task:
Write a code golf program that, given two positive integers n and m, returns a list of the distances between consecutive prime numbers in the range [n, m] ...
19
votes
12
answers
1k
views
Print Dyck paths
Definition
A Dyck path of length \2ドルn\$ can be defined as a two-dimensional path such that:
The path consists of straight lines of equal length.
The path goes left to right while moving either up or ...
2
votes
1
answer
281
views
Long running section 11.4 Minsky machine
Challenge
We define a Minsky machine as a program made of the following two instructions:
+X which increments the register X and continues to the next instruction
-Xn which simply continues if X is ...
4
votes
4
answers
561
views
Find the boolean logic to check if a number is prime!
Your task is to find a boolean expression that uses AND (\$\land\$), OR (\$\lor\$), XOR (\$\oplus\$), and NOT (\$\lnot\$) operators and binary digit positions (\$d_1,d_2,d_3,d_4,d_5,d_6,d_7,d_8,d_9,d_{...
-5
votes
4
answers
195
views
Determine if a rational number is an integer, without division [closed]
Determine if a rational number is also an integer, without any form of dividing. The input should be any pair of numerator and denominator. Don't forget to consider negative numbers, and division by ...
7
votes
1
answer
346
views
Solving the high school algebra problem
We learned many identities involving addition, multiplication and exponentiation in highschool, for example:
$$ \begin{aligned}
(a+b)c &= ac + bc \\
(a b)^c &= a^c b^c \\
(a^b)^c &= a^{bc}
...
16
votes
21
answers
2k
views
ZigZag encoding and decoding
ZigZag encoding is a method of encoding signed integers to unsigned integers. Non-negative integers are multiplied by two. Negative integers are equal to their absolute values multiplied by two, minus ...
33
votes
26
answers
9k
views
Print 4 billion if statements
Recently (okay, December 2023, I'm a little late) there's been a meme going around about a program checking if a 32-bit unsigned integer is even or odd using four billion if statements:
...
18
votes
11
answers
2k
views
Count squares in my pi approximation
One way to approximate π is the following: Start by drawing a 2x2 square with a quarter-circle in it. Then, the area of the quarter-circle is π.
We can approximate this area by filling it with ...