prime factorization of factorials using c

Solutions on MaxInterview for prime factorization of factorials using c by the best coders in the world

showing results for - "prime factorization of factorials using c"
Elias
29 Jun 2020
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}
Ryker
10 Sep 2017
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}
queries leading to this page
how to find prime factors of a number in cprime factor of a given number in cprime factorizationprime factorization using sieve in cfind c program for prime factorsprime factorization of 10prime factorization of 1prime factor program of a given number in c factorize primes in cprime factors in cprime factorization c programprime factorization of a number in cfind prime factors of a number in cwap to find prime factors of a numbersum of factorial series in cfunction is prime cprime factorization in cfinding the prime factors of a number chow to find a prime factors in cc prime factorizationprime factorization algorithm c 2b 2bprint all prime factors of a given numberprint out the prime factors of a numberc program to find prime factors of a numberfind all prime factors of a number in cseperate number in prime factor in cprogram to find prime factors of a number in chow to print out the factors of a number in cc function return prime factorprime factorization of a number c 2b 2bhow to factorise when c is a prime numberhow to find the prime factors in cprogram to get prime factors of a numberfind prime factors in cprime factor or not in cfactorize a number to the power of primes in c 2b 2bprime factor in cwrite a c program to find out prime factor of given numberwrite a function to obtain prime factors of given number in chow to find prime factors of number in cprime factorization of factorials using cc program for prime factorization of a numberc program to print prime factors of a number in cwhat is prime factor cprime factor algorithm in cprinting prime factors in cprogram to find prime factors of a numberhow to find the prime factors of a number in cwrite a c program to show the prime factor of a given number prime factors of a number in c using functionprograms regarding prime factorizationc program for prime factors of a numberhow to find all prime factors and frequencies in c 2b 2bc prime factorsprint all prime factors of a numberprime factorization c fastc program to print prime factors of a numberhow to find prime factorisation of a number in cprime factor of number c programmingprime factoring in cprime factorization program in c using pthreadwhat is the prime factorization of 14print prime factors of a number in c 22primes 7cfactor c 22prime factors of a number in cleast prime factor of a given number in cprime factor program in cprime factorization method in cprime factors cprime factors of n in c prime factor of a given number in cfind prime factorizationprime factor program of a given numberin cc program prime factorization c language prime factorsprogram for prime factors in cprime factorization of factorials using c