Highly Totient Number

A highly totient number k is an integer that has more solutions to the equation φ(x) = k, where φ is Euler’s totient function The… Read More »

Find (1^n + 2^n + 3^n + 4^n) mod 5 | Set 2

Given a very large number N. The task is to find (1n + 2n + 3n + 4n) mod 5. Examples: Input: N = 4… Read More »

Count integers in a range which are divisible by their euler totient value

Given 2 integers L and R, the task is to find out the number of integers in the range [L, R] such that they are… Read More »

Find the number of primitive roots modulo prime

Given a prime . The task is to count all the primitive roots of . A primitive root is an integer x (1 <= x… Read More »

Queries to count the number of unordered co-prime pairs from 1 to N

Given a number N. The task is to find the number of unordered coprime pairs of integers from 1 to N. There can be multiple… Read More »

Compute power of power k times % m

Given x, k and m. Compute (xxxx…k)%m, x is in power k times. Given x is always prime and m is greater than x. Examples:… Read More »

Minimum insertions to make a Co-prime array

Given an array of N elements, find the minimum number of insertions to convert the given array into a co-prime array. Print the resultant array… Read More »

Optimized Euler Totient Function for Multiple Evaluations

Euler Totient Function (ETF) Φ(n) for an input n is count of numbers in {1, 2, 3, …, n} that are relatively prime to n,… Read More »

Number Theory | Generators of finite cyclic group under addition

Given a number n, find all generators of cyclic additive group under modulo n. Generator of a set {0, 1, … n-1} is an element… Read More »

Primitive root of a prime number n modulo n

Given a prime number n, the task is to find its primitive root under modulo n. Primitive root of a prime number n is an… Read More »

Euler’s Totient function for all numbers smaller than or equal to n

Euler’s Totient function Φ(n) for an input n is count of numbers in {1, 2, 3, …, n} that are relatively prime to n, i.e.,… Read More »

Euler’s Totient Function

Euler’s Totient function ?(n) for an input n is count of numbers in {1, 2, 3, …, n} that are relatively prime to n, i.e.,… Read More »