1#include <stdio.h>
2#define MIN 100
3#define MAX 100000
4
5
6int main(){
7 int pdiv=2,j;
8 for (int num=MIN;num<=MAX;num++){
9 printf("The prime factors of %d are:\n",num);
10 j=num;
11 do {
12
13 if (j%pdiv==0)
14 {
15
16 printf("%d\n",pdiv);
17 j=j/pdiv;
18 }else
19 {
20 pdiv++;
21 }
22
23
24 }while(j>1);
25 pdiv=2;
26
27 }
28
29
30
31}
1#include <stdio.h>
2#include <math.h>
3int main()
4{
5 int N;
6 // storing prime number between 2-99
7 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};
8 int prime_index;
9 int i;
10 int power, count, store;
11 printf("\n Prime Factorization of n Factorial. The first number of parameter is prime number and 2nd number is its value.\n");
12 printf("\n\t\tType 0 to exit\n");
13 while (1)
14 {
15 printf("\nNumber : ");
16
17 scanf("%d", &N);
18 if (N == 0)
19 {
20 printf("\nThanks for using our component\n");
21 return 0;
22 }
23 if (N<2 | N> 99)
24 {
25 printf("\nType a number between 2-99\n");
26 continue;
27 }
28 for (i = 0; N >= p_arr[i]; i++)
29 {
30 prime_index = i;
31 }
32
33 printf("Factorial : ");
34 for (i = 0; i <= prime_index; i++)
35 {
36 count = 0;
37 power = 1;
38
39 for (store = N / pow(p_arr[i], power); store != 0; power++, store = N / pow(p_arr[i], power))
40 {
41 count = count + store;
42 }
43
44 if (count > 0)
45 {
46 if (i == prime_index)
47 {
48 printf("(%d,%d)", p_arr[i], count);
49 }
50 else
51 {
52 printf("(%d,%d) * ", p_arr[i], count);
53 }
54 }
55 }
56 printf("\n");
57 }
58
59 return 0;
60}