OFFSET
1,3
COMMENTS
a(1) = 0; a(n) is the smallest k such that MD5(k) < MD5(a(n-1)), where integer parameters to MD5 are encoded as base-10 ASCII strings.
If we assume that MD5 behaves like a random function from N to {0, ..., 2^128-1}, the expected length of this sequence is the harmonic number H(2^128) ~= 89.3.
a(33) > 10^15.
LINKS
Ben Whitmore, Table of n, a(n) for n = 1..32
Wikipedia, MD5
EXAMPLE
a(5) = 27 because MD5("27") = 02e74f10e0327ad868d138f2b4fdd6f0_16 = 3859480213286334249913589638377625328, which is smaller than all previous values MD5("0"), ..., MD5("26").
MATHEMATICA
recordsBy[l_, P_] :=
Module[{max = -Infinity, x, i, recs = {}},
For[i = 1, i <= Length[l], i++,
x = P[l[[i]]];
If[x > max,
max = x;
AppendTo[recs, l[[i]]];
]
];
recs
];
recordsBy[Range[1000], -Hash[ToString[#], "MD5"] &]
PROG
(Python)
from hashlib import md5
def afind(limit):
record = "~"
for k in range(limit+1):
hash = md5(str(k).encode('utf-8')).hexdigest()
if hash < record:
print(k, end=", ")
record = hash
afind(10**7) # Michael S. Branicky, Nov 24 2021
CROSSREFS
KEYWORD
nonn,base,fini,hard
AUTHOR
Ben Whitmore, Nov 23 2021
STATUS
approved