# Tag Archives: number-theory

## Midy’s theorem

According to Midy’s theorem, if the period of a repeating decimal for , where p is prime and is a reduced fraction, has an even… Read More »

## Eulerian Number

In combinatorics, the Eulerian Number A(n, m), is the number of permutations of the numbers 1 to n in which exactly m elements are greater… Read More »

## Sum of squares of first n natural numbers

Given a positive integer N. The task is to find 12 + 22 + 32 + ….. + N2. Examples: Input : N = 4… Read More »

## N-th polite number

A polite number is a positive integer that can be written as the sum of two or more consecutive positive integers. Given N, find the… Read More »

## Express an odd number as sum of prime numbers

Given an odd number, we need to express it as the sum of at most three prime numbers. Examples: Input : 27 Output : 27… Read More »

## AKS Primality Test

There are several primality test available to check whether the number is prime or not like Fermat’s Theorem, Miller-Rabin Primality test and alot more. But… Read More »

## Sexy Prime

In mathematics, Sexy Primes are prime numbers that differ from each other by six. For example, the numbers 5 and 11 are both sexy primes,… Read More »

## Schröder–Hipparchus number

The Schröder–Hipparchus numbers form an integer sequence that can be used to count the number of plane trees with a given set of leaves, the… Read More »

## Sum of squares of first n natural numbers

Given N, find sum of squares of first N natural number. Examples : Input : n = 2 Output : 5 Explanation: 1^2+2^2 = 5… Read More »

## Leyland Number

In number theory, a Leyland number is a number of the form xy + yx, where x and y are integers greater than 1 and… Read More »

## Sum of k-th group of odd positive numbers

The positive odd numbers in ascending order as 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, …. and grouped as (1), (3, 5),… Read More »

## Sum of first n odd numbers in O(1) Complexity

Given the sequence of odd numbers 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, …. Find the sum of first n… Read More »

## K-Primes (Numbers with k prime factors) in a range

Given three integers A, B and K. We need to find no. of K-prime numbers in the range [A, B]. A number is called K-prime… Read More »

## Fermat’s little theorem

Fermat’s little theorem states that if p is a prime number, then for any integer a, the number a p – a is an integer… Read More »

## Queries to print all divisors of number

Given a positive integer ‘n’ and query ‘q’. Print all the divisors of number ‘n’. Input: 6 Output: 1 2 3 6 Explanation Divisors of… Read More »