Saturday, May 16, 2009

Greatest Common Divisor (GCD), Least Common Multiple (LCM)

This calculator takes two numbers and finds the greatest common divisor and the least common multiple. If you multiply the gcm by the lcd you get the same as multiplying the two original numbers.

Friday, May 1, 2009

Prime Factors Calculator

I made this javascript prime factors calculator and have found it addictive. I just keep factorizing numbers. Enter the number to factorize in the left box and click on the 'factorize' button. The prime factors are shown in the right box.


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:

numberprime factors
1111
1113,37
111111,101
1111141,271
1111113,7,11,13,37
1111111239,4649
1111111111,73,101,137
1111111113,3,37,333667
111111111111,41,271,9091
1111111111121649,513239
1111111111113,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.