Write a c program to find a power of even prime numbers in n factorial
Answers
Answered by
0
Answer:
Explanation:Input : n = 4, p = 2
Output : 3
Power of 2 in prime factorization
of 2 in 4! = 24 is 3
Input : n = 24, p = 2
Output : 22
Answered by
1
Answer:
#include <stdio.h>
int main()
{
int n;
printf("Enter the number ");
scanf("%d",&n);
long fac=1;
int m=n;
while(n>1) // calculating factorial
{
fac*=n;
n--;
}
int count=0;
while(fac%2==0) //counting power of 2
{
count++;
fac/=2;
}
printf("power of even prime i.e 2 in factorial of %d is %d",m,count);
return 0;
}
Explanation:
Hope it helps :-)
Similar questions
English,
6 months ago
Hindi,
6 months ago
Biology,
1 year ago
Business Studies,
1 year ago
Math,
1 year ago