How to make this program?
Posted 03 September 2006 - 12:23 PM
Posted 04 September 2006 - 07:12 AM
Anyway, in what language?
You should explain yourself better
Posted 05 September 2006 - 01:50 AM
If none, I would advise you try to Google for it, and theres a posibility that someone has made such a program before, and made it available.
Posted 05 September 2006 - 01:50 PM
Really hard! This problem is known to be in NP, though it is not known whether it is NP-complete (computationally infeasible). I discussed NP and NP-completeness before here:
I want to know how to make a program that asks the user to enter a number and then displays all its factors.
Wikipedia describes a number of the standard algorithms for factorization.
None of them is very good though, keep in mind! They will work only for small enough numbers that you can solve the problem largely by brute force. Factoring very large numbers is VERY hard --- in fact, if you could find an efficient way to do it you would break most known cryptographic systems including RSA, which are used to encrypt bank data. So if you solve this problem watch your back and take all your money out of the bank!
Hope this helps.
EDIT: I'll be more specific. If you are just trying to factor small numbers n, the obvious brute-force approach is just to iterate through all integers less than or equal to (n / 2) and test whether they divide evenly into n (i.e. in C test whether (n % i) == 0 for all i <= n/2). All the numbers that match are the divisors. Then you have to sift through those to find the prime factors, if that is what you want (or if you want all the divisors, you have them).
This algorithm will get very slow as n gets even moderately large (like > 1000 or 10000 or I dunno, it depends on your hardware).
Edited by Swandog46, 05 September 2006 - 01:54 PM.
Posted 05 September 2006 - 02:49 PM
Posted 10 September 2006 - 02:24 AM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users