📅  最后修改于: 2022-03-11 15:04:37.099000             🧑  作者: Mango
#include
#include
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("\n Prime Factorization of n Factorial. The first number of parameter is prime number and 2nd number is its value.\n");
printf("\n\t\tType 0 to exit\n");
while (1)
{
printf("\nNumber : ");
scanf("%d", &N);
if (N == 0)
{
printf("\nThanks for using our component\n");
return 0;
}
if (N<2 | N> 99)
{
printf("\nType a number between 2-99\n");
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("\n");
}
return 0;
}