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

learn more… | top users | synonyms

11
votes
4answers
477 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 n. For example, 18 is a practical ...
4
votes
6answers
264 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 positive ...
14
votes
6answers
826 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: 1 -> 1 # 1/1 = 1.0000...... = 1._0 2 -> 1 ...
12
votes
5answers
232 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 integer n ...
6
votes
13answers
456 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 ...
3
votes
1answer
199 views

Decompose a range in aligned blocks of size 2^n

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 ...
4
votes
7answers
331 views

Nth K-Ugly Number

Write the shortest code in any language of your choice to find the Nth K-ugly number. A K-ugly number is a number whose only prime factors are the prime numbers <= K. This K-ugly number is ...
5
votes
3answers
443 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, ...
15
votes
6answers
986 views

Find largest prime which is still a prime after digit deletion

Over at http://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 ...
7
votes
5answers
348 views

Bijection between binary strings and pairs thereof

Input: Either one or two strings of '0's and '1's. If there are 2, they are separated by a space. All strings are of length at least 1. Output: If one string was input, 2 are output. If 2 were ...
2
votes
2answers
308 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 ...
3
votes
2answers
628 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 order. For example, for n = 10 the output would be: 1: 2: 2^1 3: 3^1 4: 2^2 5: 5^1 6: 2^1 3^1 7: 7^1 8: 2^3 ...
9
votes
9answers
874 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 ...
15
votes
35answers
1k views

Undulant numbers

An undulant number is a number where its digits go up and down like the following number: 461902 or 708143, or even 1010101, but not 123, because 2 < 3. write function which returns true if a ...
2
votes
9answers
339 views

Another amicable number problem

Two numbers are said to be 'amicable' or 'friends' if the sum of the divisors of the first is equal to the second, and viceversa. For example, the divisors of 220 are: 1, 2, 4, 5, 10, 11, 20, 22, ...
13
votes
7answers
460 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 ...
5
votes
4answers
502 views

Greatest greatest common divisor

Find the greatest gcd of the numbers nm + k and (n+1)m + k for given m and k. For example, for m=3, k=1 we have: gcd(1^3 + 1, 2^3 + 1) = 1 gcd(2^3 + 1, 3^3 + 1) = 1 ... gcd(5^3 + 1, 6^3 + 1) = 7 ...
9
votes
4answers
437 views

Last k digits of Powers of 2

For any integer, r, there exists a power of 2 each of whose last r digits are either 1 or 2. Given r, find the smallest x such that 2x mod 10r consists of only 1 or 2. For r = 2, x = 9, ...
5
votes
6answers
403 views

Modulo code golf

Write a function f(a,b) that returns a mod b given the constrains: you can't use division in any way f(a,b) is always positive, eg: f(-1,5) = 4 it performs reasonably well for values of ~10e50 for a ...
9
votes
7answers
786 views

Hamming numbers

Given a positive integer, print that many hamming numbers, in order. Rules: positive integer <= 1,000,000 execution time < 1 minute shortest code wins