|
-
May 10th, 2010, 03:09 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Math question: Finding divisors.
Is there an efficient way to find all the divisors of a number that leave no remainder? And by efficient, I don't mean dividing a number by every other number to see if the remainder is zero.
Prefix has no suffix, but suffix has a prefix.
-
May 10th, 2010, 05:00 AM
#2
Re: Math question: Finding divisors.
I could be wrong but I don't think there are easy solutions for this, not for big numbers anyway.
If you had a list of all prime numbers up to N, then you could use that list to determine the factors of numbers up to N², this would be more efficient than testing with every number.
You could write a variant of the Sieve of Eratosthenes where rather than just marking composites you log the prime factors.
Check out...
Rational sieve
Special number field sieve
General number field sieve
The latter two made my little brain hurt
-
May 10th, 2010, 02:35 PM
#3
Re: Math question: Finding divisors.
If there was a truly easy method to find this other than a brute force approach, then modern computer security would become garbage, since it is based on the very difficulty of factoring large numbers even for powerful computers.
My usual boring signature: Nothing
 
-
May 10th, 2010, 06:23 PM
#4
Re: [RESOLVED] Math question: Finding divisors.
Ehehe... no. But you can loop through them, too! 
Code:
Dim factors As New List(Of Integer)
If numbertofactor = 0 Then Exit Sub
For i As Integer = 0 To (numbertofactor \ 2) + 1
If (numbertofactor Mod i) = 0 Then factors.Add(i)
Next
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|