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
How can a program be made to print the name of a source file where an error occurs?
How can you be sure that a program follows the ANSI C standard?
What is a file descriptor in c?
1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. The Logic should be written in Data Structures?
What is array in C
What is nested structure?
What is header file in c?
Which is the best website to learn c programming?
What is a const pointer in c?
What is NULL pointer?
What is LINKED LIST? How can you access the last element in a linked list?
What is the Purpose of 'extern' keyword in a function declaration?
What does double pointer mean in c?
What is p in text message?
Tell me is null always defined as 0(zero)?