# we want the following: # # \sum_{i=0}^{N} \left ( 1-\frac{1}{64^{5}} \right )^i \cdot \frac{1}{64^{5}} # see http://pier4r.wikidot.com/pierworks:articles:obscurity-could-be-secure # excel breaks, online calculators break too somehow (it would be nice to just use sum) # therefore employing at first bc + bash, other possibilities are awk or other more equipped languages. # echo "scale=32; (1 - 1 / 64^5)^0 * ( 1 / 64^5) " | bc # .00000000093132257461547851562500 # update 2022-11-27 # Bash is ok, awk could be better in some cases. Surely both could be heavily extended by bc # but bc on its own is quite powerful in theory, if one writes libraries for it. # https://www.gnu.org/software/bc/manual/html_mono/bc.html # http://phodd.net/gnu-bc/ # so let's go full bc # usage as of 2022-11-27: # bc -l -q sum_probabilities_base_64.bc , then press enter and get the result (or use the quit command) # time bc sum_probabilities_base_64.bc for the timings. define formula (exponent) { return (1 - 1 / 64^5)^exponent * ( 1 / 64^5) } scale=32 "attempts? (+1):" ; attempts = read() sum=0 for (i = 0; i <= attempts; i++ ){ sum += formula(i) } "sum:"; sum #leave sum as output quit