#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;
}
#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;
}
}
Code Example |
---|
C :: keep last n bits |
C :: c loop |
C :: Program to input and print array elements in c |
C :: c for |
C :: malloc basics |
C :: windows forms picturebox change image |
C :: how to read 2d array from a file in c |
C :: check whether a number is prime or not in c |
C :: how to change background color in c programming |
C :: what is c |
C :: malloc c |
C :: #0000ff |
C :: to execute a program using C |
C :: powershell list big files |
C :: fahrenheit to celcius |
C :: c programming exercises |
C :: read from command line c |
C :: open a file in from terminal |
C :: c defined value sum |
C :: man strstr |
C :: printing words lemgthwise in c |
C :: 4 byte alignment c code |
C :: c hello word |
C :: Fibonacci program c pthread |
C :: %s and string pointer |
C :: pointeur de pointeur en language c |
C :: condition ternaire in c |
C :: uri/beecrowd problem no - 1133 solution in C |
C :: bullseye lxc network problem |
C :: c bind str and int |