Wieferich primes: Difference between revisions
m
Fix typo throughout, I misspelled it in the first place
Thundergnat (talk | contribs) m (Thundergnat moved page Weiferich primes to Wieferich primes: Misspelled name) |
Thundergnat (talk | contribs) m (Fix typo throughout, I misspelled it in the first place) |
||
Line 87:
sequences ;
"
5000 primes-upto [ [ 1 - 2^ 1 - ] [ sq divisor? ] bi ] filter .</lang>
{{out}}
<pre>
V{ 1093 3511 }
</pre>
Line 172:
use ntheory 'is_prime';
say '
{{out}}
<pre>
=={{header|Phix}}==
Line 180:
<span style="color: #008080;">include</span> <span style="color: #7060A8;">mpfr</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
<span style="color: #7060A8;">mpz</span> <span style="color: #000000;">z</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">mpz_init</span><span style="color: #0000FF;">()</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">
<span style="color: #7060A8;">mpz_set_str</span><span style="color: #0000FF;">(</span><span style="color: #000000;">z</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #008000;">'1'</span><span style="color: #0000FF;">,</span><span style="color: #000000;">p</span><span style="color: #0000FF;">-</span><span style="color: #000000;">1</span><span style="color: #0000FF;">),</span><span style="color: #000000;">2</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">return</span> <span style="color: #7060A8;">mpz_fdiv_q_ui</span><span style="color: #0000FF;">(</span><span style="color: #000000;">z</span><span style="color: #0000FF;">,</span><span style="color: #000000;">z</span><span style="color: #0000FF;">,</span><span style="color: #000000;">p</span><span style="color: #0000FF;">*</span><span style="color: #000000;">p</span><span style="color: #0000FF;">)=</span><span style="color: #000000;">0</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"
<!--</lang>-->
{{out}}
<pre>
</pre>
Line 197:
=={{header|REXX}}==
<lang rexx>/*REXX program finds and displays
parse arg n . /*obtain optional argument from the CL.*/
if n=='' | n=="," then n= 5000 /*Not specified? Then use the default.*/
Line 203:
numeric digits max(9, length(2**n) ) /*calculate # of decimal digits needed.*/
call genP /*build array of semaphores for primes.*/
title= '
w= length(title) + 2 /*width of field for the primes listed.*/
say ' index │'center(title, w) /*display the title for the output. */
say '───────┼'center("" , w, '─') /* " a sep for the output. */
wp= 0 /*initialize number of
do j=1 to #; p= @.j; pm= p - 1 /*search for
if (2**pm - 1) // p**2\==0 then iterate /*P**2 not evenly divide 2**(P-1) - 1?*/
wp= wp + 1 /*bump the counter of
say center(wp, 7)'│' center(commas(p), w) /*display the
end /*j*/
Line 238:
{{out|output|text= when using the default input:}}
<pre>
index │
───────┼──────────────────────────────────────
1 │ 1,093
Line 244:
───────┴──────────────────────────────────────
Found 2
</pre>
Line 254:
var primes = Int.primeSieve(5000)
System.print("
for (p in primes) {
var num = (BigInt.one << (p - 1)) - 1
Line 263:
{{out}}
<pre>
1093
3511
|