Find maximum power of a number that divides a factorial

Given two numbers, fact and n, find the largest power of n that divides fact! (Factorial of fact). Examples: Input : fact = 5, n… 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 »

Factorial of each element in Fibonacci series

Given the upper limit limit, print factorials of all Fibonacci Numbers smaller than limit. Examples : Input : limit = 20 Output : 1 1… Read More »

Program to get the Sum of series: 1 – x^2/2! + x^4/4! -…. upto nth term

This is a mathematical series program where a user must enter the number of terms up to which the sum of the series is to… Read More »

Numbers whose factorials end with n zeros

Given an integer n, we need to find the number of positive integers whose factorial ends with n zeros. Examples: Input : n = 1… Read More »

Print factorials of a range in right aligned format

Given two number m and n, the task is to find factorial of all number including m and n and then print below format. Examples:… Read More »

GCD of factorials of two numbers

Given two numbers m and n. Find the GCD of the their factorial. Examples : Input : n = 3, m = 4 Output :… Read More »

Program to check for Peterson number

A number is said to be a Peterson number if the sum of factorials of each digit of the number is equal to the number… Read More »

Largest power of k in n! (factorial) where k may not be prime

Given two numbers k and n, find the largest power of k that divides n! Constraints: K > 1 Examples: Input : n = 7,… Read More »

One line function for factorial of a number

Factorial of a non-negative integer, is multiplication of all integers smaller than or equal to n. Example : Factorial of 6 is 6 * 5… Read More »

Find all factorial numbers less than or equal to n

A number N is called a factorial number if it is the factorial of a positive integer. For example, the first few factorial numbers are… Read More »

Find the last digit when factorial of A divides factorial of B

We are given two numbers A and B such that B >= A. We need to compute the last digit of this resulting F such… Read More »

Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +…….+ n/n!

You have been given a series 1/1! + 2/2! + 3/3! + 4/4! +…….+ n/n!, find out the sum of the series till nth term.… Read More »

An interesting solution to get all prime numbers smaller than n

This approach is based on Wilson’s theorem and using the fact that factorial computation can be done easily using DP Wilson theorem says if a… Read More »

Finding power of prime number p in n!

Given a number ‘n’ and a prime number ‘p’. We need to find out the power of ‘p’ in the prime factorization of n! Examples:… Read More »