#include <stdio.h>
#include <math.h>
int main()
{
int N;
// storing prime number between 2-99
int p_arr[25] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
int prime_index;
int i;
int power, count, store;
printf("
Prime Factorization of n Factorial. The first number of parameter is prime number and 2nd number is its value.
");
printf("
Type 0 to exit
");
while (1)
{
printf("
Number : ");
scanf("%d", &N);
if (N == 0)
{
printf("
Thanks for using our component
");
return 0;
}
if (N<2 | N> 99)
{
printf("
Type a number between 2-99
");
continue;
}
for (i = 0; N >= p_arr[i]; i++)
{
prime_index = i;
}
printf("Factorial : ");
for (i = 0; i <= prime_index; i++)
{
count = 0;
power = 1;
for (store = N / pow(p_arr[i], power); store != 0; power++, store = N / pow(p_arr[i], power))
{
count = count + store;
}
if (count > 0)
{
if (i == prime_index)
{
printf("(%d,%d)", p_arr[i], count);
}
else
{
printf("(%d,%d) * ", p_arr[i], count);
}
}
}
printf("
");
}
return 0;
}