Post Reply 
Strange behaviour of prime numbers
05-26-2019, 05:08 PM (This post was last modified: 05-26-2019 05:30 PM by Albert Chan.)
Post: #11
RE: Strange behaviour of prime numbers
Hi, pier4r

Tried it with Mathematica. Distribution looks similar within sub-ranges.

Code:
keys = {1, 3, 7, 9};
joinlastdigit[x_, y_] := Mod[x, 10]*10 + Mod[y, 10];
keys = Flatten[Table[joinlastdigit[keys[[i]], keys[[j]]], {i, 4}, {j, 4}]];

lastdigitdist[range_] := Block[{n, p, t},    (* distribution percentages *)
    n = Length[range];
    p = Map[Prime, range];
    t = Map[joinlastdigit[p[[#]], p[[#+1]]]&, Range[n-1]];
    0.1 * Round[1000 * Map[Count[t, #]&, keys]/n]];

keys → {11, 13, 17, 19, 31, 33, 37, 39, 71, 73, 77, 79, 91, 93, 97, 99}

lastdigitdist[Range[1, 1000000]]        → {4.3, 7.7, 7.9, 5.0, 5.8, 4.0, 7.3, 7.9, 6.4, 6.9, 4.0, 7.8, 8.5, 6.4, 5.8, 4.3}

lastdigitdist[Range[100001, 200000]] → {4.2, 7.8, 8.1, 4.9, 5.7, 3.8, 7.4, 8.0, 6.4, 7.0, 3.9, 7.8, 8.7, 6.4, 5.7, 4.1}

lastdigitdist[Range[300001, 400000]] → {4.3, 7.7, 8.0, 5.0, 5.8, 4.0, 7.3, 7.9, 6.4, 6.9, 3.9, 7.7, 8.5, 6.4, 5.8, 4.3}

m = 10^6; (* check next million primes *)
lastdigitdist[Range[m+1, m+m]]        → {4.4, 7.6, 7.8, 5.2, 5.9, 4.1, 7.2, 7.8, 6.4, 6.9, 4.1, 7.6, 8.3, 6.4, 5.9, 4.4}
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Strange behaviour of prime numbers - Albert Chan - 05-26-2019 05:08 PM



User(s) browsing this thread: 1 Guest(s)