# Questions tagged [number-theory]

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

378 questions
Filter by
Sorted by
Tagged with
2k views

### Calculate practical numbers

Definition A positive integer n is a practical number (OEIS sequence A005153) iff all smaller positive integers can be represented as sums of distinct divisors of <...
2k views

### Print n weird numbers

A weird number is a number that the sum of proper divisors is greater than the number itself and no subset of proper divisors sum to that number. Examples: 70 is a weird number because its proper ...
977 views

### Count how many numbers are divisible by perfect numbers in a given range

Given two arbitrary integers $a$ and $b$, count how many numbers are divisible by perfect numbers in that given range ($a$ and $b$ both are inclusive). In mathematics, a perfect number is a ...
1k views

### Period of the decimal representation

Write a function which takes a single positive integer n and returns the period of the decimal representation of 1/n. Test cases: ...
792 views

### Hardy–Ramanujan number generalization

$1729$, known as the Hardy–Ramanujan number, is the smallest positive integer that can be expressed as the sum of two cubes of positive integers in two ways ($12^3+1^3=10^3+9^3=1729$). Given an ...
4k views

### List the first 20 friendly number pairs

I just started reading about friendly numbers and I think they sound great. In number theory, friendly numbers are two or more natural numbers with a common abundancy, the ratio between the sum of ...
312 views

### Decompose a range in aligned blocks of size 2^n [closed]

Given an arbitrary contiguous range of positive integers, find the decomposition in the minimum number of sub-ranges of size L = 2^n, with the constraint that each range must be aligned, that is the ...
1k views

### N Doors, K Monkeys

There are N doors and K monkeys. Initially, all the doors are closed. Round 1: The 1st monkey visits every door and toggles the door (if the door is closed, it gets opened it; if it is open, it gets ...
1k views

### Nth K-Ugly Number

Write the shortest code in any language of your choice to find the $N$th $K$-ugly number. A $K$-ugly number is a number whose only prime factors are the prime numbers $\le K$. $K$-ugly ...
1k views

### Evaluate the primorial of a number [duplicate]

The primorial of a number is the product of all the primes until that number, itself included. Take a number from STDIN as the input and evaluate its primorial, ...
2k views

### The making of “Spot It!”: Finding almost unique sets

Puzzle: Find a deck of c cards, each containing p pictures, such that no two pictures match on a given card, and exactly 1 picture on each card matches exactly 1 picture on each of the other cards, ...
2k views

### Find largest prime which is still a prime after digit deletion

Over at https://math.stackexchange.com/questions/33094/deleting-any-digit-yields-a-prime-is-there-a-name-for-this the following question is asked. How many primes are there that remain prime after you ...
767 views

### Bijection between binary strings and pairs thereof

Input: Either one or two strings consisting of '0's and '1's. If there are 2, they are separated by a space. All strings are of ...
513 views

### List ALL prime-factorized natural numbers in ANY order

This is a variant of List prime-factorized natural numbers up to N in ascending order, but the solutions can be very different. Write a program that outputs prime factorizations of all natural ...
1k views

### List prime-factorized natural numbers up to N in ascending order

For a given n list prime factorization of all natural numbers between 1 and n in ascending ...
3k views

### Calculate hamming weight with low hamming weight

Create a program that computes the hamming weight of a string. Winner is the program with the lowest hamming weight. Rules: Hamming weight for an ASCII character is defined as the total number of ...
2k views

### Undulant numbers [duplicate]

An undulant number is a number where its digits alternate between up and down like the following number: 461902 or 708143, or even 1010101, but not 123, because 2 < 3. Write a program or function ...
749 views

### Another amicable number problem

Two numbers are said to be 'amicable' or 'friends' if the sum of the proper divisors of the first is equal to the second, and viceversa. For example, the proper divisors of 220 are: 1, 2, 4, 5, 10, ...
902 views

### Square Number Digit Density

The square number digit density (SNDD) of a number - invented by myself - is the ratio of the count of square numbers found in consecutive digits to the length of the number. For instance, 169 is a 3-...
3k views

### Find the prime factors

In this task, you have to write a program, that computes the prime factors of a number. The input is a natural number 1 < n < 2^32. The output is a list of the prime factors of the number in the ...
Find the greatest gcd of the numbers $n^m + k$ and $(n+1)^m + k$ for given m and k. For example, for ...