Skip to main content

Questions tagged [number-theory]

Number theory involves properties and relationships of numbers, primarily positive integers.

Filter by
Sorted by
Tagged with
6 votes
2 answers
258 views

Minimal Triangles

Make an upside down triangle of positive integers. Every number in the triangle must be distinct. Each number is the summation of its two parents (similar to how Pascal's triangle is constructed, but ...
AdmBorkBork's user avatar
  • 43.4k
22 votes
11 answers
960 views

Digit Product Sequences

Here's an interesting sequence discovered by Paul Loomis, a mathematician at Bloomsburg University. From his page on this sequence: Define ...
AdmBorkBork's user avatar
  • 43.4k
5 votes
27 answers
2k views

Simple Factorial Challenge [duplicate]

In light of today's date... A factorial of a number n, is the product of all the numbers from 1 to n inclusive. The Challenge Given an integer n where 0 <= n <= 420, find the sum of the digits ...
NL628's user avatar
  • 723
17 votes
14 answers
2k views

Conway's Prime Game

Specifically, Conway's PRIMEGAME. This is an algorithm devised by John H. Conway to generate primes using a sequence of 14 rational numbers: ...
AdmBorkBork's user avatar
  • 43.4k
16 votes
13 answers
1k views

Seidel Triangle

The Seidel Triangle is a mathematical construction similar to Pascal's Triangle, and is known for it's connection to the Bernoulli numbers. The first few rows are: ...
Bolce Bussiere's user avatar
9 votes
5 answers
406 views

Four Spiraling Axes

Take the numbers 0, 1, 2, 3, 4, ... and arrange them in a clockwise spiral, starting downward, writing each digit in its own separate square. Then, given one of ...
AdmBorkBork's user avatar
  • 43.4k
23 votes
32 answers
2k views

Rotational Average

Given an input integer n >= 10, output the average of all deduplicated rotations of the integer. For example, for input 123, ...
AdmBorkBork's user avatar
  • 43.4k
32 votes
6 answers
2k views

1, 2, 3, 14... or is it 15?

A well known song by the Irish rock band U2 starts with the singer Bono saying "1, 2, 3, 14" in Spanish ("uno, dos, tres, catorce"). There are various theories as to the significance of those numbers....
Luis Mendo's user avatar
  • 105k
4 votes
3 answers
278 views

unRSA: solve the private key

Given positive integer n and e, knowing that e<n and that ...
l4m2's user avatar
  • 24.5k
22 votes
5 answers
485 views

Swap program halves to test divisors

Four integer sequences In this challenge, you will test four different properties of a positive integer, given by the following sequences. A positive integer N is perfect (OEIS A000396), if the sum ...
Zgarb's user avatar
  • 42.7k
11 votes
10 answers
1k views

Some Lonely Primes

I know, I know, yet another primes challenge... Related A lonely (or isolated) prime is a prime number p such that p-2, ...
AdmBorkBork's user avatar
  • 43.4k
21 votes
14 answers
2k views

Is this a truncated triangular number?

Related OEIS sequence: A008867 Truncated triangular number A common property of triangular numbers is that they can be arranged in a triangle. For instance, take 21 and arrange into a triangle of <...
JungHwan Min's user avatar
  • 13.8k
11 votes
3 answers
970 views

Crazy but Rational Bases

We have many challenges based on base 10, base 2, base 36, or even base -10, but what about all the other rational bases? Task Given an integer in base 10 and a rational base, return the integer in ...
JungHwan Min's user avatar
  • 13.8k
12 votes
5 answers
709 views

Sparse Protractor

Given some positive integer n, design a protractor with the fewest number of marks that lets you measure all angles that are an integral multiple of ...
flawr's user avatar
  • 43.8k
31 votes
10 answers
1k views

Find the dot product of Rationals

I was at a friend's house for dinner and they suggested the idea of a "Prime-factor vector space". In this space the positive integers are expressed as a vector such that the nth element in the ...
Wheat Wizard's user avatar
  • 98.8k
10 votes
5 answers
434 views

Continued Fraction of Digit-wise Sum of Square Roots

Introduction Your task is to generate the first 1000 terms in the continued fraction representation of digit-wise sum of square root of 2 and square root of 3. In other words, produce exactly the ...
Weijun Zhou's user avatar
  • 3,647
14 votes
1 answer
1k views

Regex for multiples of 9

It is easy to describe a finite state machine that recognizes multiples of 9: keep track of the digit sum (mod 9) and add whatever digit is accepted next. Such a FSM has only 9 states, very simple! By ...
Alex Meiburg's user avatar
-3 votes
1 answer
154 views

Find prime factors of sum of non-composite Fibonacci numbers up to n

The Challenge Given a number, find the sum of the non-composite numbers in the Fibonacci sequence up to that number, and find the prime factors of the sum. For example, if you were given 8, the non-...
rappatic's user avatar
  • 111
24 votes
22 answers
3k views

Bertrand's Primes

Bertrand's Postulate states that for every integer n ≥ 1 there is at least one prime p such that n < p ≤ 2n. In order to verify this theorem for n < 4000 ...
flawr's user avatar
  • 43.8k
14 votes
9 answers
1k views

Verify Cyclic Difference Sets

A cyclic difference set is a set of positive integers with a unique property: Let n be the largest integer in the set. Let r be ...
PhiNotPi's user avatar
  • 29.1k
25 votes
35 answers
3k views

Pascal's Triangle (Sort of)

Most everyone here is familiar with Pascal's Triangle. It's formed by successive rows, where each element is the sum of its two upper-left and upper-right neighbors. Here are the first ...
AdmBorkBork's user avatar
  • 43.4k
15 votes
15 answers
1k views

The modulo parity party

You are given an array A of n strictly positive integers, with n ≥ 2. Your task is to map each entry Ai to: 1 if Aj mod Ai is odd for each j such that 1 ≤ j ≤ n and j ≠ i 2 if Aj mod Ai is even for ...
Arnauld's user avatar
  • 193k
20 votes
23 answers
2k views

Make Zero From First 'n' Numbers

Challenge The challenge is to write a code that takes a positive integer 'n' as an input and displays all the possible ways in which the numbers from 1 - n can be written, with either positive or ...
Manish Kundu's user avatar
  • 5,290
33 votes
8 answers
1k views

Can square tree rings be generated from primes?

Apparently yes! In three easy steps. Step 1 Let f(n) denote the prime-counting function (number of primes less than or equal to n). Define the integer sequence s(n) as follows. For each positive ...
Luis Mendo's user avatar
  • 105k
26 votes
22 answers
2k views

Diluted Integer Sums

A positive integer can be diluted by inserting a 0 between two bits in its binary expansion. This means that an n-bit number has ...
AdmBorkBork's user avatar
  • 43.4k
24 votes
12 answers
2k views

Write numbers as a difference of Nth powers

Challenge There are many numbers which can be expressed as the difference of two squares, or as the difference of two cubes, or maybe even higher powers. Talking about squares, there are various ways ...
Manish Kundu's user avatar
  • 5,290
13 votes
15 answers
1k views

Minimise the count of prime factors through insertion

Given two positive integers A and B, return the position p that minimises the number of prime factors (counting multiplicities) of the resulting integer, when B is inserted in A at p. For example, ...
Mr. Xcoder's user avatar
  • 42.4k
9 votes
20 answers
1k views

Prime numbers between n and 2n [duplicate]

Bertrand's postulate states that there is always at least 1 prime number between n and 2n for all n greater than 1. Challenge Your task is to take a positive integer n greater than 1 and find all of ...
buttercrab's user avatar
21 votes
16 answers
3k views

Recursive Collatz Conjecture

The Collatz conjecture postulates that if you take any positive integer, then repeat the following algorithm enough times: ...
DonielF's user avatar
  • 773
20 votes
37 answers
3k 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 ...
Addison Crump's user avatar
22 votes
2 answers
870 views

Write it into number theory style

Write a mathematical statement, using the symbols: There exists at least one non-negative integer (written as E, existential ...
l4m2's user avatar
  • 24.5k
20 votes
16 answers
2k views

Factor-poor numbers

If a positive integer \$N > 2\$ has (strictly) less prime factors (without counting multiplicities) than its successor and its predecessor, we will call it a factor-poor number. In other words, \$...
Mr. Xcoder's user avatar
  • 42.4k
20 votes
21 answers
2k views

Determine Superabundance

A superabundant number is an integer n that sets a new upper bound for its ratio with the divisor sum function σ. In other words, n is superabundant if and only if, for all positive integers x ...
Nissa's user avatar
  • 3,634
7 votes
6 answers
375 views

Count of relatively prime partitions

The partitions of an integer N are all the combinations of integers smaller than or equal to N and higher than 0 which sum up to N. A relatively prime partition is an integer partition, but whose ...
user avatar
29 votes
20 answers
3k views

Is this a three-digit number ending in one?

Given a nonnegative integer, return whether it is a three digit number ending in one, in any consistent integer base. In other words, the number needs to be represented in base-N, N being an integer ...
HAEM's user avatar
  • 671
14 votes
25 answers
1k views

Calculate the Upper Divmod

Task Given two positive integers (dividend and divisor), calculate the quotient and the remainder. Normally it would be calculated as e = o*q+r where ...
Rod's user avatar
  • 18.4k
13 votes
21 answers
2k views

Iterated phi sequence

Related: Iterated phi(n) function. Your challenge is to compute the iterated phi function: f(n) = number of iterations of φ for n to reach 1. Where ...
Simply Beautiful Art's user avatar
14 votes
27 answers
2k views

Calculate the lowest number where the sum of the sequence of numbers exceeds a given value

Given you have an infinite sequence of numbers defined as follows: ...
StudleyJr's user avatar
  • 285
13 votes
10 answers
1k views

Repeated Digit Primes

Another sequence, another challenge.* Definition A prime p is in this sequence, let's call it A, iff for every digit ...
AdmBorkBork's user avatar
  • 43.4k
20 votes
10 answers
2k 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 ...
Luis Mendo's user avatar
  • 105k
11 votes
9 answers
2k views

Compute the Lambert W function

Your challenge is to compute the Lambert W function. \$W(x)\$ is defined to be the real value(s) \$y\$ such that $$y = W(x) \text{ if } x = ye^y$$ where \$e = 2.718281828...\$ is Euler's number. ...
Simply Beautiful Art's user avatar
11 votes
18 answers
1k views

Do we share the prime cluster?

The prime cluster of an integer N higher than 2 is defined as the pair formed by the highest prime strictly lower than N and the lowest prime strictly higher than N. Note that following the definition ...
Mr. Xcoder's user avatar
  • 42.4k
13 votes
10 answers
615 views

Counting Fibonacci Orbits

If we define a Fibonacci-like sequence as fk(n) = (fk(n-1) + fk(n-2)) % k, for some integer k (where % is the modulo operator), the sequence will necessarily be cyclic, because there are only k2 ...
Martin Ender's user avatar
72 votes
26 answers
9k views

Yo boy, must it sum

Every positive integer can be expressed as the sum of at most three palindromic positive integers in any base b≥5.   Cilleruelo et al., 2017 A positive integer is palindromic in a given base if ...
Luis Mendo's user avatar
  • 105k
22 votes
28 answers
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 ...
user avatar
12 votes
23 answers
2k views

Sum the means of the two integers

There are quite a few means in mathematics, such as the arithmetic mean, the geometric mean, and many others... Definitions and Task Note that these are the definitions for two positive integers*: ...
Mr. Xcoder's user avatar
  • 42.4k
15 votes
33 answers
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). ...
Gryphon's user avatar
  • 7,235
20 votes
3 answers
701 views

Writing rational numbers as ratio of factorials of primes

Note: this challenge has been posted on the sandbox. Introduction This challenge is inspired by 2009 Putnam B1, a problem in an undergraduate mathematics competition. The problem is as follows: ...
Carl Schildkraut's user avatar
12 votes
7 answers
1k views

Golf the pseudoprimes!

Introduction / Background In a recent discussion in the crypto chat I was challenged to discuss / help with the Fermat primality test and Carmichael numbers. This test is based on the premise that <...
SEJPM's user avatar
  • 3,393
6 votes
3 answers
381 views

Primitive roots density of number

Definition: A number m is called a primitive root of a prime p the condition that the smallest integer k for which p dividies mk-1 is p-1 Your task Given a tuple (a,b) of positive integers, return ...
katana_0's user avatar
  • 209

1 2 3
4
5
10