Write a program to generate prime factors of a given integer?

Answer Posted / kalee

Pseudo code: Algorithm ....

If N is the integer, then, any number greater than sqrt(N) will not be a factor of that integer...

so it is enough to check till sqrt(N) integers, that is it is divisible or not... further, if N is odd... forget all the even integers, as they cannot be a part of factors.. :)

Happy coding...

Is This Answer Correct ?    6 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is a 'locale'?

579


Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?

649


How will you divide two numbers in a MACRO?

702


write a program to generate address labels using structures?

4003


What is the size of structure in c?

695






Can we compile a program without main() function?

628


What are the 5 data types?

594


Why do we write return 0 in c?

545


Explain the use of keyword 'register' with respect to variables.

586


What is the difference between specifying a constant variable like with constant keyword and #define it? i.e what is the difference between CONSTANT FLOAT A=1.25 and #define A 1.25

1488


What is the advantage of a random access file?

637


A collection of functions,calls,subroutines or other data a) library b) header files c) set of files d) textfiles

641


What is the difference between int main and void main in c?

589


You have given 2 array. You need to find whether they will create the same BST or not. For example: Array1:10 5 20 15 30 Array2:10 20 15 30 5 Result: True Array1:10 5 20 15 30 Array2:10 15 20 30 5 Result: False One Approach is Pretty Clear by creating BST O(nlogn) then checking two tree for identical O(N) overall O(nlogn) ..we need there exist O(N) Time & O(1) Space also without extra space .Algorithm ?? DevoCoder guest Posted 3 months ago # #define true 1 #define false 0 int check(int a1[],int a2[],int n1,int n2) { int i; //n1 size of array a1[] and n2 size of a2[] if(n1!=n2) return false; //n1 and n2 must be same for(i=0;ia1[i+1]) && (a2[i]>a2[i+1]) ) ) return false; } return true;//assumed that each array doesn't contain duplicate elements in themshelves }

2706


What is hungarian notation? Is it worthwhile?

689