Search
 
SCRIPT & CODE EXAMPLE
 

C

prime factorization of factorials using C

#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;
}
Comment

prime factorization in c

#include <stdio.h>
#define MIN 100
#define MAX 100000


int main(){
    int pdiv=2,j;
    for (int num=MIN;num<=MAX;num++){
        printf("The prime factors of %d are:
",num);
        j=num;
        do {
            
            if (j%pdiv==0)
            {
                
                printf("%d
",pdiv);
                j=j/pdiv;
            }else
            {
               pdiv++; 
            }
            
            
        }while(j>1);
        pdiv=2;
        
    }



}
Comment

PREVIOUS NEXT
Code Example
C :: C program to check whether character is lowercase or not using ASCII values 
C :: bd number regex 
C :: equal string c 
C :: how i send custom data in model field rest_framework serializer 
C :: How to convert string to int without using library functions in c 
C :: how to convert int in to const char in c 
C :: prime factorization in c 
C :: how to use malloc in c 
C :: malloc basics 
C :: c convert string to size_t 
C :: Palindrome number in c program 
C :: string array in c 
C :: replace a substring with another substring in c 
C :: C strlen implementation 
C :: ecrire programme en C une fonction remplir tableau et un fonction inverser 
C :: powershell list big files 
C :: definir função em c 
C :: how to join an array of strings c 
C :: function that changes all lowercase letters of a string to uppercase. 
C :: %= in c 
C :: boolean operators in c 
C :: c convert float to int 
C :: fine print serial key 
C :: spacemacs start server 
C :: how can i learn c game development 
C :: send an array through a pipe 
C :: extended euclidean algorithm to find x and y 
C :: arcolinux 
C :: Reverse every Word of given String 
C :: passing an array to a function 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =