# Tag Archives: number-theory

## Count square and non-square numbers before n

Given a number n, we need to count square numbers smaller than or equal to n. Examples : Input : n = 5 Output :… Read More »

## Trailing number of 0s in product of two factorials

Given two integer N or M find the number of zero’s trailing in product of factorials (N!*M!)? Examples: Input : N = 4, M =… Read More »

## Average of odd numbers till a given odd number

Given an odd number n, find the average of odd numbers from 1 to n. Examples: Input : n = 9 Output : 5 Explanation… Read More »

## Sum of fifth powers of the first n natural numbers

Write a program to find the sum of Fifth powers of the first n natural numbers 15 + 25+ 35 + 45+ …….+ n5 till… Read More »

## Program to compare two fractions

Given two fractions a/b and c/d, compare them and print the larger of the two. Examples : Input: 5/6, 11/45 Output: 5/6 Input: 4/5 and… Read More »

## Sum of square of first n odd numbers

Given a number n, find sum of square of first n odd natural numbers. Examples : Input : 3 Output : 35 12 + 32… Read More »

## Sum of square of first n even numbers

Given a number n, find sum of square of first n even natural numbers. Examples : Input : 3 Output : 56 22 + 42… Read More »

## Program to check if N is a Pentagonal Number

Given a number (N), check if it is pentagonal or not. Examples : Input: 12 Output: Yes Explanation: 12 is the third pentagonal number Input:… Read More »

## Sum of fourth powers of the first n natural numbers

Write a program to find the sum of fourth powers of the first n natural numbers 14 + 24 + 34 + 44 + …….+… Read More »

## Aliquot sum

In number theory, the aliquot sum s(n) of a positive integer n is the sum of all proper divisors of n, that is, all divisors… Read More »

## Divide 1 to n into two groups with minimum sum difference

Given a positive integer n such that n > 2. Divide numbers from 1 to n in two groups such that absolute difference of sum… Read More »

## Find sum of even factors of a number

Given a number n, the task is to find the even factor sum of a number. Examples: Input : 30 Output : 48 Even dividers… Read More »

## Find remainder of array multiplication divided by n

Given multiple numbers and a number n, the task is to print the remainder after multiply all the number divide by n. Examples: Input :… Read More »

## Find sum of odd factors of a number

Given a number n, the task is to find the odd factor sum. Examples : Input : n = 30 Output : 24 Odd dividers… Read More »

## Program for Mobius Function

Mobius Function is a multiplicative function which is used in combinatorics. It has one of three possible values -1, 0 and 1. Examples: Input :… Read More »