::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:
: An odd number in the range 2^32 to 2^64 is prime if it passes an SPRP-2 test
: and one or two more SPRP tests using bases in this table.
:
: The table has 16384 16 bit entries designating a pair of bases. Select an
: element using a hash of the odd number with: (#AD625B89 _* N) // 18
:
: The operator "_*" is unsigned 32 bit multiplication and "//" shifts right.
: This hashing mechanism originated with Steven Worley's 32 bit primality test.
:
: 2^32 to 2^49: Pass SPRP-2 and a second SPRP test using the hashed base.
:
: 2^49 to 2^64: Pass an addition SPRP test using one of 8 bases selected
: using the upper 3 bits of the hashed base. These bases are:
: 0 .. 7 ==> {15, 135, 13, 60, 15, 117, 65, 29}
:
: N = 871_87753_77449
: SPRP( N, 2 ) = 1
: Hash = #d4ee_f6f1 // 18 = #353b = 13627
: Base = 687
: SPRP( N, 687 ) = 1 (prime)
:
: N = 865_17769_13431 (555871 * 15564361)
: SPRP( N, 2 ) = 1
: Hash = #3d6c_a94f // 18 = #5fb = 3931
: Base = 767
: SPRP( N, 767 ) = 0 (composite)
:
: N = 3315_29345_21928_21991
: SPRP( N, 2 ) = 1
: Hash = #40eda9f // 18 = #103 = 259
: Base = 8638
: SPRP( N, 8638 ) = 1
: Base = Second[ Base // 13 ] = 135
: SPRP( N, 135 ) = 1 (prime)
:
: N = 1152_96599_65919_97761 (619937093 * 1859811277)
: SPRP( N, 2 ) = 1
: Hash = #9417_38c9 // 18 = #2505 = 9477
: Base = 1941
: SPRP( N, 1941 ) = 1
: Base = Second[ Base // 13 ] = 15
: SPRP( N, 15 ) = 0 (composite)
:
:* Copyright 2018 Bradley Berg < (My last name) @ t e c h n e o n . c o m >
:*
:* Permission to use, copy, modify, and distribute this software for any
:* purpose with or without fee is hereby granted, provided that the above
:* copyright notice and this permission notice appear in all copies.
:*
:
: This algorithm is deliberately unpatented. The license above also
: lets you even freely use it in commercial code.
:
: Primality testing using a hash table of bases originated with Steven Worley.
:...............................................................................
Discussion
Jeffrey Hurchalla. "An Improved Integer Modular Multiplicative Inverse (modulo2^w )" [2204.04342] (2022).
Forisek, Michal and Jakub Jancina. “Fast Primality Testing for Integers That Fit into a Machine Word.” Conference on Current Trends in Theory and Practice of Informatics (2015).
FJ32_256:FJ64_16k:FJ64_262k:すみません、こちらの記事の
sqrt_newtonを自作のライブラリに含めて公開したい (ライセンスは未定) のですが大丈夫ですか?著作表記などできるだけご意向に沿いたいと考えています。「むしろ表記しないでほしいし、勝手にしてほしい」という感じであればそのようにしたいと思います。
以上です、よろしくお願い致します。
sqrt_newton関数のソースコード部分に関しては、 CC0 https://creativecommons.org/publicdomain/zero/1.0/legalcode.ja 相当とします。利用に関して何か問題が生じた場合においても、自己責任にてお願いします。実装の誤りで正しい結果を得られなかったケースもあったようですので、念の為。
大変素早い返信ありがとうございます。
CC0 との旨、承知いたしました。