2022-01-16から1日間の記事一覧
ヴィーフェリッヒ素数http://commutative.world.coocan.jp/blog5/2020/11/post-182.html 関数化と Primes パッケージの isprime() を使うことによりほぼ 15 倍速となった。元のプログラムと比較して欲しい。 using Primesfunction Wiefelich() z = BigInt(1)…
黄金比の値をニュートン法により小数点以下 n 桁まで求める。 function newton(n=10000) prec = floor(Int, n / log10(2)) setprecision(prec+10) x = BigFloat(2) err = BigFloat(10) for i in 1:1000 xn = (x^2+1) / (2x-1) i > 1 && string(xn)[end-5:end…
ユークリッド-マリン数列http://commutative.world.coocan.jp/blog5/2022/01/post-523.html 元のプログラムでは第 6 項の 50207 までなら 0.035977 秒で計算できる。しかし,第 7 項まで出そうとすると 1912.027524 秒かかる。しかも出てきた答え 547985393…