Generating Multiples of 13
In the times when I was still superstitious I was playing around with the number 13 and came up with a formula to get a new multiple of 13 from an existing multiple of 13. The process of how to do it is described below.
Given a number m = a0 + a1 * 10 + a2 * 102 + … + am * 10m that is a M13 (i.e. m mod 13 = 0), you can apply the following formula to it and get another number n that is also a M13:
n = 2 * ( am + am-1 * 10 + am-2 * 102 + … + a0 * 10m) + 2 * ( a1 + a2 - a4 - a5 + a7 + a8 - … )
The code below - written in Ruby - gets the corresponding n number from an initial m number:
Posted in Mathematics and tagged with Prime Numbers.