factorial c program using for loop
#include<stdio.h>
int main(){
int i,f=1,num;
printf("Enter a number: ");
scanf("%d",&num);
for(i=1;i<=num;i++)
f=f*i;
printf("Factorial of %d is: %d",num,f);
return 0;
}
factorial c program using for loop
#include<stdio.h>
int main(){
int i,f=1,num;
printf("Enter a number: ");
scanf("%d",&num);
for(i=1;i<=num;i++)
f=f*i;
printf("Factorial of %d is: %d",num,f);
return 0;
}
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("n Prime Factorization of n Factorial. The first number of parameter is prime number and 2nd number is its value.n");
printf("nttType 0 to exitn");
while (1)
{
printf("nNumber : ");
scanf("%d", &N);
if (N == 0)
{
printf("nThanks for using our componentn");
return 0;
}
if (N<2 | N> 99)
{
printf("nType a number between 2-99n");
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;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us