Write a program to generate prime factors of a given integer?
Answer Posted / shruthi chandran
voiid primeFactors(int n)
{
while (n%2 == 0)
{
printf("%d ", 2);
n = n/2;
}
for (int i = 3; i <= sqrt(n); i = i+2)
{
while (n%i == 0)
{
printf("%d ", i);
n = n/i;
}
}
if (n > 2)
printf ("%d ", n);
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What are type modifiers in c?
#include main() { char s[] = "Bouquets and Brickbats"; printf(" %c, ",*(&s[2])); printf("%s, ",s+5); printf(" %s",s); printf(" %c",*(s+2)); }
explain what is fifo?
write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?
How do you do dynamic memory allocation in C applications?
What are different types of variables in c?
What are pragmas and what are they good for?
What is default value of global variable in c?
What is difference between main and void main?
What are the types of i/o functions?
How to declare pointer variables?
What is the significance of c program algorithms?
What are the 32 keywords in c?
How can I do serial ("comm") port I/O?
What the advantages of using Unions?