形式
Plain text
投稿日時
2022-11-27 20:26
公開期間
無期限
  1. # we want the following:
  2. # # \sum_{i=0}^{N} \left ( 1-\frac{1}{64^{5}} \right )^i \cdot \frac{1}{64^{5}}
  3. # see http://pier4r.wikidot.com/pierworks:articles:obscurity-could-be-secure
  4. # excel breaks, online calculators break too somehow (it would be nice to just use sum)
  5. # therefore employing at first bc + bash, other possibilities are awk or other more equipped languages.
  6. # echo "scale=32; (1 - 1 / 64^5)^0 * ( 1 / 64^5) " | bc
  7. # .00000000093132257461547851562500
  8. # update 2022-11-27
  9. # Bash is ok, awk could be better in some cases. Surely both could be heavily extended by bc
  10. # but bc on its own is quite powerful in theory, if one writes libraries for it.
  11. # https://www.gnu.org/software/bc/manual/html_mono/bc.html
  12. # http://phodd.net/gnu-bc/
  13. # so let's go full bc
  14. # usage as of 2022-11-27:
  15. # bc -l -q sum_probabilities_base_64.bc , then press enter and get the result (or use the quit command)
  16. # time bc sum_probabilities_base_64.bc for the timings.
  17. define formula (exponent) {
  18. return (1 - 1 / 64^5)^exponent * ( 1 / 64^5)
  19. }
  20. scale=32
  21. "attempts? (+1):" ; attempts = read()
  22. sum=0
  23. for (i = 0; i <= attempts; i++ ){
  24. sum += formula(i)
  25. }
  26. "sum:"; sum #leave sum as output
  27. quit
ダウンロード 印刷用表示

このコピペの URL

JavaScript での埋め込み

iframe での埋め込み

元のテキスト