I've never had a push button prime factor generator before.
You can easily check if a number is prime. It only has one prime factor: itself.
It's easy to generate a large prime number. Just type in a long random number and get its prime factors. If one of the factors is large, you've found a large prime number. If you don't get one, try changing your random number slightly.
For example: 384339387 gives 3,37,3462517. So 3462517 is a nice large prime number.
I like adding an extra digit and seeing what factors come out:
number | prime factors |
11 | 11 |
111 | 3,37 |
1111 | 11,101 |
11111 | 41,271 |
111111 | 3,7,11,13,37 |
1111111 | 239,4649 |
11111111 | 11,73,101,137 |
111111111 | 3,3,37,333667 |
1111111111 | 11,41,271,9091 |
11111111111 | 21649,513239 |
111111111111 | 3,7,11,13,37,101,9901 |
All the numbers with an even number of ones have the factor 11. And those with 4, 8 and 12 ones have factors of 11 and 101 because 1111 = 11 X 101.
Those with an odd number of ones have only two prime factors, except 111111111 (nine ones). I wonder if there's something going on here?
Oh no, the next number lets me down: 1111111111111 has factors 53,79 and 265371653.
If you find any interesting patterns with this prime factors calculator, let me know.
nice toy for very small numbers =)
ReplyDeletetry this number: 2287930740466177.
You'll get correct answer, but you have to wait. Now try this one: 1569079426997587189. The answer of your script is incorrect.
Hmmmm. When I put in 1569079426997587189 it gives me the factors for 1569079426997587200.
ReplyDeleteWith a bit of trial an error I've found that it seems to work for numbers up to 2**53 = 9007199254740992
The limitation is either with Javascript's Math.abs() or parseInt() function or both. This is changing the input number before it is factorized. I'll have a look when I get some more time...
"I can't factor that number, but here's one I can do".
Even without the Math.abs() and parseInt() the calculation still fails for 2**53 + 1. So I've put in a limit with a maximum number of 2**53 - 1.
ReplyDeleteI would have made 2**53 the maximum, as it factors this ok, but the '>' comparison in Javascipt can't tell the difference between 2*53 and 2*53 + 1.
(2**53 + 1) > (2**53) returns false in Javascript!
> If you find any interesting patterns with this prime factors calculator, let me know.
ReplyDeleteIf I found a pattern in primes, I'd tell you right after my Nobel prize :P
for 111111111 3,3,37,333667
ReplyDeletebut 333667 is NOT prime!!
If 333667 is not prime, what are its divisors?
ReplyDeleteI like trying phone numbers.
ReplyDelete