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


Please Help Members By Posting Answers For Below Questions

Why do we need a structure?

580


What is quick sort in c?

577


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

606


find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2

1522


What are the salient features of c languages?

619






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.

1475


Why n++ execute faster than n+1 ?

1835


What is a null string in c?

579


How will you find a duplicate number in a array without negating the nos ?

1637


What is the time and space complexities of merge sort and when is it preferred over quick sort?

671


What is Dynamic memory allocation in C? Name the dynamic allocation functions.

551


What is array in C

701


How can I access an I o board directly?

618


What is multidimensional arrays

624


What are the parts of c program?

627