Clarphimous
2008-11-18, 08:19
A while back (back in high school, actually) I programmed a program for the TI-83+ that goes through factoring numbers. I thought it would be nice if it could test to see if it's a prime number before continuing the factoring. The problem is, the calculator only has up to 13 digits of accuracy in its calculations, and can only work with numbers less than 100 digits. One of the equations I found for testing for compositeness is
(a^n - a)
a is an integer greater than or equal to 2, and n is your number you're testing. If n does not divide evenly into that number, it is not prime.
fPart((a^n - a)/n) = 0
Problem is, if I'm testing any number above 47, I'm going to get a number larger than 13 digits. If used as-is, it's completely useless to me.
Is there some way to break the calculation up so it doesn't have to use such large numbers, or is there some other method that can work, or is this just a waste of my time? Pretty much every method I saw besides trial division had a^n in it. Maybe I should work on implementing something like wheel factoring instead?
Here are the pages I was looking at:
http://primes.utm.edu/prove/index.html
And here's a very fast factorization program that I've looked at:
http://www.alpertron.com.ar/ECM.HTM
Well, at least it's fast compared to my program... many orders of magnitude faster.
Like, I enter 8979845161989798708094513 as the number to test, and it turns out to be prime. It calculates this in less than one second. If it really took 2^n, that would be a vast amount of memory taken up. There's got to be something I'm missing here.
(a^n - a)
a is an integer greater than or equal to 2, and n is your number you're testing. If n does not divide evenly into that number, it is not prime.
fPart((a^n - a)/n) = 0
Problem is, if I'm testing any number above 47, I'm going to get a number larger than 13 digits. If used as-is, it's completely useless to me.
Is there some way to break the calculation up so it doesn't have to use such large numbers, or is there some other method that can work, or is this just a waste of my time? Pretty much every method I saw besides trial division had a^n in it. Maybe I should work on implementing something like wheel factoring instead?
Here are the pages I was looking at:
http://primes.utm.edu/prove/index.html
And here's a very fast factorization program that I've looked at:
http://www.alpertron.com.ar/ECM.HTM
Well, at least it's fast compared to my program... many orders of magnitude faster.
Like, I enter 8979845161989798708094513 as the number to test, and it turns out to be prime. It calculates this in less than one second. If it really took 2^n, that would be a vast amount of memory taken up. There's got to be something I'm missing here.