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
Why do we need a structure?
What is quick sort in c?
c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above
find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2
What are the salient features of c languages?
Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create.
Why n++ execute faster than n+1 ?
What is a null string in c?
How will you find a duplicate number in a array without negating the nos ?
What is the time and space complexities of merge sort and when is it preferred over quick sort?
What is Dynamic memory allocation in C? Name the dynamic allocation functions.
What is array in C
How can I access an I o board directly?
What is multidimensional arrays
What are the parts of c program?