Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

What are type modifiers in c?

1056


#include main() { char s[] = "Bouquets and Brickbats"; printf(" %c, ",*(&s[2])); printf("%s, ",s+5); printf(" %s",s); printf(" %c",*(s+2)); }

1135


explain what is fifo?

1079


write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?

2139


How do you do dynamic memory allocation in C applications?

1089


What are different types of variables in c?

1080


What are pragmas and what are they good for?

1001


What is default value of global variable in c?

994


What is difference between main and void main?

1215


What are the types of i/o functions?

1349


How to declare pointer variables?

1248


What is the significance of c program algorithms?

1147


What are the 32 keywords in c?

1094


How can I do serial ("comm") port I/O?

1184


What the advantages of using Unions?

1233