Skip to main content

Questions tagged [integer]

For challenges involving the manipulation of integers.

17 votes
7 answers
1k views

English to Dutch number order conversion

Introduction: When saying numbers out loud, the order is slightly different in Dutch than in English. For a number like \$1234\$: in English you'd say: one thousand, two hundred and thirty-four in ...
Kevin Cruijssen's user avatar
13 votes
16 answers
1k 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 <...
SquareFinder's user avatar
20 votes
31 answers
2k 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 (...
SquareFinder's user avatar
12 votes
12 answers
735 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 ...
Fmbalbuena's user avatar
  • 5,085
10 votes
2 answers
366 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 ...
Fmbalbuena's user avatar
  • 5,085
11 votes
11 answers
758 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 ...
Fmbalbuena's user avatar
  • 5,085
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 ...
caird coinheringaahing's user avatar
2 votes
13 answers
675 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] ...
JuanCa's user avatar
  • 361
19 votes
12 answers
1k views

Print Dyck paths

Definition A Dyck path of length \$2n\$ 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 ...
Luis Mendo's user avatar
  • 107k
3 votes
1 answer
297 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 ...
malediscord kitten's user avatar
4 votes
4 answers
580 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_{...
Fmbalbuena's user avatar
  • 5,085
-5 votes
4 answers
204 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 ...
Gabriel Tellez's user avatar
7 votes
1 answer
355 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} ...
Trebor's user avatar
  • 805
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 ...
Jordan's user avatar
  • 11.9k
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: ...
emanresu A's user avatar
  • 46.2k

15 30 50 per page
1
2 3 4 5
31