# Questions tagged [number-theory]

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

371 questions
Filter by
Sorted by
Tagged with
3k views

### Narcissistic loop lengths

A narcissistic number is a natural number which is equal to the sum of its digits when each digit is taken to the power of the number digits. For example $8208 = 8^4 + 2^4 + 0^4 + 8^4$, so is ...
450 views

### Repetend length in 1/n

This problem is based on non-terminating, repeating decimal points. Let $n$ be any positive integer $(n > 1 \text{ and } n < 10000)$, say $7$. Then, $1/n = 1/7 = 0.142857142857142857...$ ...
1k views

### Count the Collatz survivors mod 2^n

Introduction We have 22 Collatz conjecture-related challenges as of October 2020, but none of which cares about the restrictions on counter-examples, if any exists, to the conjecture. Considering a ...
2k views

### Find a divisibility pattern

Background Sometimes when I'm golfing a program, I'm presented with the following situation: I have an integer value $x$ on some fixed interval $[a, b]$, and I'd like to test whether it's in some ...
436 views

1k views

### Find the Inverse Neighbor Pairs

Definition We say a pair of integers $(a,b)$, where $0<a<b<N$ and $N$ is an integer larger than 4, is an inverse neighbor pair respect to $N$ if $ab\equiv1\text{ }(\text{mod }N)$ ...
378 views

### Dirichlet Convolution Inverse

If $f,g\colon \mathbb{Z}_{\geq 1} \to \mathbb{R}$, the Dirichlet convolution of $f$ and $g$ is defined by $\qquad\qquad\qquad \displaystyle (f*g)(n) = \sum_{d|n}f(d)g(n/d).$ This ...
2k views

### Longest Prime Sums

Sandbox There are special sets S of primes such that $\sum\limits_{p\in S}\frac1{p-1}=1$. In this challenge, your goal is to find the largest possible set of primes that satisfies this condition. ...
3k views

### Who's next to me in the queue?

Problem 4 in the 2019 BMO, Round 1 describes the following setup: There are $2019$ penguins waddling towards their favourite restaurant. As the penguins arrive, they are handed tickets numbered ...
2k views

### Next Shared Totient

The totient function $\phi(n)$, also called Euler's totient function, is defined as the number of positive integers $\le n$ that are relatively prime to (i.e., do not contain any factor in common ...
4k views

### Fermat's Last Theorem, mod n

Fermat's Last Theorem, mod n It is a well known fact that for all integers $p>2$, there exist no integers $x, y, z>0$ such that $x^p+y^p=z^p$. However, this statement is not true in ...
2k views

### Fermat's polygonal number theorem

Fermat's polygonal number theorem states that every positive integer can be expressed as the sum of at most $n$ $n$-gonal numbers. This means that every positive integer can be expressed as the ...
1k views

404 views

### Impatient divisibility test

Your task is to write a program or function that determines whether a number is divisible by another. The catch is that it should give an answer as soon as possible, even if not all digits of the ...
762 views

### Make the biggest and smallest numbers

Inspired by this post over on Puzzling. Spoilers for that puzzle are below. Given three positive integers as input, (x, y, z), construct the inclusive range ...
2k views

### The number of ways a number is a sum of consecutive primes

Given an integer greater than 1, output the number of ways it can be expressed as the sum of one or more consecutive primes. Order of summands doesn't matter. A sum can consist of a single number (...
658 views

### Compute the minimum $a(n)>a(n-1)$ such that $a(1)+a(2)+\dots+a(n)$ is prime (OEIS A051935)

Background Consider the following sequence (A051935 in OEIS): Start with the term $2$. Find the lowest integer $n$ greater than $2$ such that $2+n$ is prime. Find the lowest integer $n'$ ...
625 views

### Split the bits!

We define $V(x)$ as the list of distinct powers of $2$ that sum to $x$. For instance, $V(35)=[32,2,1]$. By convention, powers are sorted here from highest to lowest. But it does not affect ...