Comment

Austin City Limits: The Milk Carton Kids w/ Sarah Jarosz: 'Years Gone By'

49
Belafon2/13/2014 7:22:06 pm PST

Can someone translate mathematica? Here’s the code (source at link):

f[n_Integer] := Flatten[ Table[ #1] & @@@ FactorInteger[n]]; NextPrim[n_] := Block[ {k = n + 1}, While[ !PrimeQ[k], k++ ]; k]; m = 2; Do[ While[p = f[m]; l = Length[p]; t = Table[m + i, {i, 0, n - 1}]; k = 1; While[k < l + 1 && Union[ Mod[t, NestList[ NextPrim, p[[k]], n - 1]]] != {0}, k++ ]; k == l + 1, m++ ]; Print[m], {n, 2, 50}]

I know what it’s supposed to do, but I’m trying to figure out the details. Each loop finds the first number in a sequence of n numbers such that the first is divisible by 2, the second by 3, the third by 5, … the nth number by the nth prime (for example 158 is divisible by 2, 159 by 3, 160 by 5, and 161 by 7). The particular detail I am looking for is that if its on a number, m, say 241028, and m does not start a valid sequence, does the inner loop try 241029 next or 271058?

Thanks.