(09-30-2024, 10:59 AM)Jack Wrote: thanks eoredson
that is fine for small integers but that method is not practical for 70 digit integers, there may be cases where that would work but in general it's not practical
First thing I'd check with 70 digit numbers would be:
SELECT CASE RIGHT$(STR$(num),1)
CASE 2, 4, 6, 8, 0 '2 is a factor. simplify by that amount
CASE 5 '5 is a factor, simplify by that amount
CASE ELSE 'may be a prime as all primes above 10 end in 1, 3, 7, 9
'this case is the one where you're going to end having to your string math
'but if it's smaller than an INT64 by the time you get to this point (which is close to 18 digits, if I remember correctly)
'then you can just do this with normal numbers and not have to do string math
'either way, you've managed to simplify 60% of all numbers before you ever got to this complex processing point, and that's a nice WIN
END SELECT