Birthday in Pi

That looks like Mathematica, not Matlab? You could do this with a regex.

julia> function pi_str(n)
           setprecision(Int(ceil(log2(10) * n))) do
               string(BigFloat(pi))
           end
       end

julia> m = match(r"(111799)", pi_str(10^6))
RegexMatch("111799", 1="111799")

julia> m.offset
123957
3 Likes