This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This Crystal source file is a multiple threaded implementation to perform an | |
| # extremely fast Segmented Sieve of Zakiya (SSoZ) to find Primes <= N. | |
| # Compile as: $ crystal build --release -Dpreview_mt --mcpu native primes_ssoz.cr | |
| # To reduce binary size do: $ strip primes_ssoz | |
| # Thread workers default to 4, set to system max for optimum performance. | |
| # Single val: $ CRYSTAL_WORKERS=8 ./primes_ssoz val1 | |
| # Range vals: $ CRYSTAL_WORKERS=8 ./primes_ssoz val1 val2 | |
| # val1 and val2 can be entered as either: 123456789 or 123_456_789 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This Rust source file is a multiple threaded implementation to perform an | |
| // extremely fast Segmented Sieve of Zakiya (SSoZ) to find Primes <= N. | |
| // Inputs are single values N, or ranges N1 and N2, of 64-bits, 0 -- 2^64 - 1. | |
| // Output is the number of twin primes <= N, or in range N1 to N2; the last | |
| // twin prime value for the range; and the total time of execution. | |
| // Can compile as: $ cargo build --release | |
| // or: $ RUSTFLAGS="-C opt-level=3 -C debuginfo=0 -C target-cpu=native" cargo build --release | |
| // The later compilation creates faster runtime on my system. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #[ | |
| This Nim source file is a multiple threaded implementation to perform an | |
| extremely fast Segmented Sieve of Zakiya (SSoZ) to find Cousin Primes <= N. | |
| Inputs are single values N, or ranges N1 and N2, of 64-bits, 0 -- 2^64 - 1. | |
| Output is the number of cousin primes <= N, or in range N1 to N2; the last | |
| cousin prime value for the range; and the total time of execution. | |
| Code originally developed on a System76 laptop with an Intel I7 6700HQ cpu, | |
| 2.6-3.5 GHz clock, with 8 threads, and 16GB of memory. Parameter tuning |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This Rust source file is a multiple threaded implementation to perform an | |
| // extremely fast Segmented Sieve of Zakiya (SSoZ) to find Cousin Primes <= N. | |
| // Inputs are single values N, or ranges N1 and N2, of 64-bits, 0 -- 2^64 - 1. | |
| // Output is the number of cousin primes <= N, or in range N1 to N2; the last | |
| // cousin prime value for the range; and the total time of execution. | |
| // Can compile as: $ cargo build --release | |
| // or: $ RUSTFLAGS="-C opt-level=3 -C debuginfo=0 -C target-cpu=native" cargo build --release | |
| // The later compilation creates faster runtime on my system. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* This D source file is a multiple threaded implementation to perform an | |
| * extremely fast Segmented Sieve of Zakiya (SSoZ) to find Cousin Primes <= N. | |
| * | |
| * Inputs are single values N, or ranges N1 and N2, of 64-bits, 0 -- 2^64 - 1. | |
| * Output is the number of cousin primes <= N, or in range N1 to N2; the last | |
| * cousin prime value for the range; and the total time of execution. | |
| * | |
| * Code originally developed on a System76 laptop with an Intel I7 6700HQ cpu, | |
| * 2.6-3.5 GHz clock, with 8 threads, and 16GB of memory. Parameter tuning | |
| * would be needed to optimize for other hadware systems (ARM, PowerPC, etc). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This Go source file is a multiple threaded implementation to perform an | |
| // extremely fast Segmented Sieve of Zakiya (SSoZ) to find Cousin Primes <= N. | |
| // Inputs are single values N, or ranges N1 and N2, of 64-bits, 0 -- 2^64 - 1. | |
| // Output is the number of cousiin primes <= N, or in range N1 to N2; the last | |
| // cousin prime value for the range; and the total time of execution. | |
| // Code originally developed on a System76 laptop with an Intel I7 6700HQ cpu, | |
| // 2.6-3.5 GHz clock, with 8 threads, and 16GB of memory. Parameter tuning | |
| // probably needed to optimize for other hardware systems (ARM, PowerPC, etc). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| This C++ source file is a multiple threaded implementation to perform an | |
| extremely fast Segmented Sieve of Zakiya (SSoZ) to find Cousin Primes <= N. | |
| Inputs are single values N, or ranges N1 and N2, of 64-bits, 0 -- 2^64 - 1. | |
| Output is the number of cousin primes <= N, or in range N1 to N2; the last | |
| cousin prime value for the range; and the total time of execution. | |
| Code originally developed on a System76 laptop with an Intel I7 6700HQ cpu, | |
| 2.6-3.5 GHz clock, with 8 threads, and 16GB of memory. Parameter tuning |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This Crystal source file is a multiple threaded implementation to perform an | |
| # extremely fast Segmented Sieve of Zakiya (SSoZ) to find Cousin Primes <= N. | |
| # Compile as: $ crystal build --release -Dpreview_mt --mcpu native cousinprimes_ssoz_newref.cr | |
| # To reduce binary size do: $ strip cousinprimes_ssoz | |
| # Thread workers default to 4, set to system max for optimum performance. | |
| # Single val: $ CRYSTAL_WORKERS=8 ./cousinprimes_ssoz val1 | |
| # Range vals: $ CRYSTAL_WORKERS=8 ./cousinprimes_ssoz val1 val2 | |
| # val1 and val2 can be entered as either: 123456789 or 123_456_789 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "big" | |
| module IntRoots | |
| def irootn(n : Int32) | |
| raise ArgumentError.new "Can't take even root of negative input" if self < 0 && n.even? | |
| raise ArgumentError.new "Root must be an Integer >= 2" unless n.is_a?(Int) && n > 1 | |
| num = self.abs | |
| one = typeof(self).new(1) # value 1 of type self | |
| root = bitn_mask = one << (num.bit_length - 1) // n | |
| until (bitn_mask >>= 1) == 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| This C++ source file is a multiple threaded implementation to perform an | |
| extremely fast Segmented Sieve of Zakiya (SSoZ) to find Twin Primes <= N. | |
| Inputs are single values N, or ranges N1 and N2, of 64-bits, 0 -- 2^64 - 1. | |
| Output is the number of twin primes <= N, or in range N1 to N2; the last | |
| twin prime value for the range; and the total time of execution. | |
| Code originally developed on a System76 laptop with an Intel I7 6700HQ cpu, | |
| 2.6-3.5 GHz clock, with 8 threads, and 16GB of memory. Parameter tuning |
NewerOlder