Primes which contain only one odd digit: Difference between revisions

m
(→‎{{header|Wren}}: Stretched to primes under 1 billion.)
m (→‎{{header|Wren}}: Minor tidy)
 
(11 intermediate revisions by 8 users not shown)
Line 2:
 
;Task
Show on this page those primes under   '''1,000'''   which when expressed in decimal containscontain only one odd digit.
 
 
;Stretch goal:
Show on this page only the &nbsp; <u>count</u> &nbsp; of those primes under &nbsp; '''1,000,000''' &nbsp; which when expressed in decimal containscontain only one odd digit.
<br><br>
 
=={{header|11l}}==
{{trans|Nim}}
<syntaxhighlight lang="11l">F is_prime(n)
 
<lang 11l>F is_prime(n)
I n == 2
R 1B
Line 39 ⟶ 38:
I hasLastDigitOdd(n) & is_prime(n)
count++
print("\nFound "count‘ primes with only one odd digit below 1000000.’)</langsyntaxhighlight>
 
{{out}}
Line 55 ⟶ 54:
=={{header|Action!}}==
{{libheader|Action! Sieve of Eratosthenes}}
<langsyntaxhighlight Actionlang="action!">INCLUDE "H6:SIEVE.ACT"
 
BYTE FUNC OddDigitsCount(INT x)
Line 86 ⟶ 85:
OD
PrintF("%E%EThere are %I primes",count)
RETURN</langsyntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Primes_which_contain_only_one_odd_digit.png Screenshot from Atari 8-bit computer]
Line 98 ⟶ 97:
=={{header|ALGOL 68}}==
{{libheader|ALGOL 68-primes}}
<langsyntaxhighlight lang="algol68">BEGIN # find primes whose decimal representation contains only one odd digit #
# sieve the primes to 1 000 000 #
PR read "primes.incl.a68" PR
Line 132 ⟶ 131:
OD;
show total( p1odd count, UPB prime, "single-odd-digit" )
END</langsyntaxhighlight>
{{out}}
<pre>
Line 144 ⟶ 143:
Found 2560 single-odd-digit primes upto 1000000
</pre>
 
=={{header|Arturo}}==
<syntaxhighlight lang="arturo">onlyOneOddDigit?: function [n][
and? -> prime? n
-> one? select digits n => odd?
]
 
primesWithOnlyOneOddDigit: select 1..1000 => onlyOneOddDigit?
 
loop split.every: 9 primesWithOnlyOneOddDigit 'x ->
print map x 's -> pad to :string s 4
 
nofPrimesBelow1M: enumerate 1..1000000 => onlyOneOddDigit?
 
print ""
print ["Found" nofPrimesBelow1M "primes with only one odd digit below 1000000."]</syntaxhighlight>
 
{{out}}
 
<pre> 3 5 7 23 29 41 43 47 61
67 83 89 223 227 229 241 263 269
281 283 401 409 421 443 449 461 463
467 487 601 607 641 643 647 661 683
809 821 823 827 829 863 881 883 887
 
Found 2560 primes with only one odd digit below 1000000.</pre>
 
=={{header|AWK}}==
<syntaxhighlight lang="awk">
<lang AWK>
# syntax: GAWK -f PRIMES_WHICH_CONTAIN_ONLY_ONE_ODD_NUMBER.AWK
BEGIN {
Line 176 ⟶ 201:
return(1)
}
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 199 ⟶ 224:
=={{header|C#|CSharp}}==
Modifies a conventional prime sieve to cull the items with more than one odd digit.
<langsyntaxhighlight lang="csharp">using System;
using System.Collections.Generic;
 
Line 246 ⟶ 271:
}
}
</syntaxhighlight>
</lang>
{{out}}
<pre>List of one-odd-digit primes < 1,000:
Line 264 ⟶ 289:
Found 46,708 one-odd-digit primes < 10^8 (100,000,000)
Found 202,635 one-odd-digit primes < 10^9 (1,000,000,000)</pre>
 
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|SysUtils,StdCtrls}}
 
 
<syntaxhighlight lang="Delphi">
function IsPrime(N: int64): boolean;
{Fast, optimised prime test}
var I,Stop: int64;
begin
if (N = 2) or (N=3) then Result:=true
else if (n <= 1) or ((n mod 2) = 0) or ((n mod 3) = 0) then Result:= false
else
begin
I:=5;
Stop:=Trunc(sqrt(N+0.0));
Result:=False;
while I<=Stop do
begin
if ((N mod I) = 0) or ((N mod (I + 2)) = 0) then exit;
Inc(I,6);
end;
Result:=True;
end;
end;
 
 
 
procedure GetDigits(N: integer; var IA: TIntegerDynArray);
{Get an array of the integers in a number}
var T: integer;
begin
SetLength(IA,0);
repeat
begin
T:=N mod 10;
N:=N div 10;
SetLength(IA,Length(IA)+1);
IA[High(IA)]:=T;
end
until N<1;
end;
 
 
 
procedure ShowOneOddDigitPrime(Memo: TMemo);
var I,Cnt1,Cnt2: integer;
var IA: TIntegerDynArray;
var S: string;
 
function HasOneOddDigit(N: integer): boolean;
var I,Odd: integer;
begin
Odd:=0;
GetDigits(N,IA);
for I:=0 to High(IA) do
if (IA[I] and 1)=1 then Inc(Odd);
Result:=Odd=1;
end;
 
begin
Cnt1:=0; Cnt2:=0;
S:='';
for I:=0 to 1000000-1 do
if IsPrime(I) then
if HasOneOddDigit(I) then
begin
Inc(Cnt1);
if I<1000 then
begin
Inc(Cnt2);
S:=S+Format('%4D',[I]);
If (Cnt2 mod 5)=0 then S:=S+CRLF;
end;
end;
Memo.Lines.Add(S);
Memo.Lines.Add('Count < 1,000 = '+IntToStr(Cnt2));
Memo.Lines.Add('Count < 1,000,000 = '+IntToStr(Cnt1));
end;
 
 
</syntaxhighlight>
{{out}}
<pre>
3 5 7 23 29
41 43 47 61 67
83 89 223 227 229
241 263 269 281 283
401 409 421 443 449
461 463 467 487 601
607 641 643 647 661
683 809 821 823 827
829 863 881 883 887
 
Count < 1,000 = 45
Count < 1,000,000 = 2560
Elapsed Time: 171.630 ms.
</pre>
 
=={{header|F_Sharp|F#}}==
This task uses [http://www.rosettacode.org/wiki/Extensible_prime_generator#The_functions Extensible Prime Generator (F#)]
<langsyntaxhighlight lang="fsharp">
// Primes which contain only one odd number. Nigel Galloway: July 28th., 2021
let rec fN g=function 2->false |n when g=0->n=1 |n->fN (g/10) (n+g%2)
primes32()|>Seq.takeWhile((>)1000)|>Seq.filter(fun g->fN g 0)|>Seq.iter(printf "%d "); printfn ""
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 280 ⟶ 404:
{{libheader|Factor-numspec}}
{{works with|Factor|0.99 2021-06-02}}
<langsyntaxhighlight lang="factor">USING: grouping io lists lists.lazy literals math math.primes
numspec prettyprint ;
 
Line 301 ⟶ 425:
 
"\nCount of such primes under 1,000,000,000:" print
p [ 1,000,000,000 < ] lwhile llength .</langsyntaxhighlight>
{{out}}
<pre>
Line 319 ⟶ 443:
 
=={{header|FreeBASIC}}==
<langsyntaxhighlight lang="freebasic">
#include "isprime.bas"
 
Line 326 ⟶ 450:
dim as uinteger m = int(log(n-1)/log(5))
return int((n-1-5^m)/5^j)
end function
 
function evendig(n as uinteger) as uinteger
'produces the integers with only even digits
Line 349 ⟶ 473:
wend
 
print "There are ";count;" such primes below one million."</langsyntaxhighlight>
 
=={{header|Go}}==
{{trans|Wren}}
{{libheader|Go-rcu}}
<langsyntaxhighlight lang="go">package main
 
import (
Line 377 ⟶ 501:
const (
LIMIT = 999
LIMIT2 = 9999999999999999
MAX_DIGITS = 3
)
Line 394 ⟶ 518:
}
}
fmt.Println("\nFound", len(results), "such primes.\n")
 
primes = rcu.Primes(LIMIT2)
count := 0
pow := 10
for _, prime := range primes[1:] {
if allButOneEven(prime) {
count = count + 1+
}
if prime > pow {
fmt.Printf("There are %7s such primes under %s\n", rcu.Commatize(count), rcu.Commatize(pow))
pow *= 10
}
}
csfmt.Printf("There :=are %7s such primes under %s\n", rcu.Commatize(count), rcu.Commatize(pow))
}</syntaxhighlight>
ls := rcu.Commatize(LIMIT2 + 1)
fmt.Println("\nThere are", cs, "primes under", ls, "which contain only one odd digit.")
}</lang>
 
{{out}}
Line 419 ⟶ 546:
Found 45 such primes.
 
There are 2,560 primes under 1,000,000 which contain only3 onesuch oddprimes under digit.10
There are 12 such primes under 100
There are 45 such primes under 1,000
There are 171 such primes under 10,000
There are 619 such primes under 100,000
There are 2,560 such primes under 1,000,000
There are 10,774 such primes under 10,000,000
There are 46,708 such primes under 100,000,000
There are 202,635 such primes under 1,000,000,000
There are 904,603 such primes under 10,000,000,000
</pre>
 
=={{header|Haskell}}==
<langsyntaxhighlight lang="haskell">import Data.List (intercalate, maximum, transpose)
import Data.List.Split (chunksOf)
import Data.Numbers.Primes (primes)
Line 462 ⟶ 598:
let ws = maximum . fmap length <$> transpose rows
pw = printf . flip intercalate ["%", "s"] . show
in unlines $ intercalate gap . zipWith pw ws <$> rows</langsyntaxhighlight>
{{Outout}}
<pre>Below 1000:
3 5 7 23 29 41 43 47 61 67
Line 473 ⟶ 609:
Count of matches below 10E6:
2560</pre>
 
=={{header|J}}==
<syntaxhighlight lang="j"> getOneOdds=. #~ 1 = (2 +/@:| "."0@":)"0
primesTo=. i.&.(p:inv)
 
_15 ]\ getOneOdds primesTo 1000
3 5 7 23 29 41 43 47 61 67 83 89 223 227 229
241 263 269 281 283 401 409 421 443 449 461 463 467 487 601
607 641 643 647 661 683 809 821 823 827 829 863 881 883 887
 
# getOneOdds primesTo 1e6
2560</syntaxhighlight>
 
=={{header|jq}}==
Line 478 ⟶ 626:
'''Works with gojq, the Go implementation of jq'''
 
As noted in the [[#Julia|Julia entry]], if only one digit of a prime is odd, then that digit is in the ones place. The first solution presented here uses this observation to generate plausible candidates. The second solution is more brutish and slower but simpler.
 
See e.g. [[Erd%C5%91s-primes#jq]] for a suitable implementation of `is_prime`.
 
===Fast solution===
<langsyntaxhighlight lang="jq">### Preliminaries
 
def count(s): reduce s as $x (null; .+1);
Line 490 ⟶ 638:
label $out | stream | if cond then break $out else . end;
 
# Output: an unbounded stream
def primes_with_exactly_one_odd_digit:
# Output: a stream of candidate strings, in ascending numerical order
Line 515 ⟶ 663:
emit_until(. > 1000; primes_with_exactly_one_odd_digit),
 
"\nThe number of primes less than 1000000 with exactly one odd digits is \(count(emit_until(. > 1000000; primes_with_exactly_one_odd_digit)))."</langsyntaxhighlight>
{{out}}
<pre>
Line 567 ⟶ 715:
</pre>
===A simpler but slower solution===
<langsyntaxhighlight lang="jq"># Input is assumed to be prime.
# So we only need check the other digits are all even.
def prime_has_exactly_one_odd_digit:
Line 578 ⟶ 726:
# It is much faster to check for primality afterwards.
range(3; infinite; 2)
| select(prime_has_exactly_one_odd_digit and is_prime);</langsyntaxhighlight>
 
=={{header|Julia}}==
If only one digit of a prime is odd, then that odd digit is the ones place digit. We don't actually need to check for an odd first digit once we exclude 2.
<langsyntaxhighlight lang="julia">using Primes
 
function isoneoddprime(n, base = 10)
Line 595 ⟶ 743:
println("\nThere are ", count(isoneoddprime, primes(1_000_000)),
" primes with only one odd digit in base 10 between 1 and 1,000,000.")
</langsyntaxhighlight>{{out}}
<pre>
Found 45 primes with one odd digit in base 10:
Line 606 ⟶ 754:
There are 2560 primes with only one odd digit in base 10 between 1 and 1,000,000.
</pre>
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<lang Mathematica>Labeled[Cases[
<syntaxhighlight lang="mathematica">Labeled[Cases[
NestWhileList[NextPrime,
2, # <
Line 616 ⟶ 765:
2, # <
1000000 &], _?(Total[Mod[IntegerDigits@#, 2]] ==
1 &)], "Number of primes < 1,000,000 with one odd digit", Top]</langsyntaxhighlight>
 
{{out}}<pre>
Line 627 ⟶ 776:
 
=={{header|Nim}}==
<langsyntaxhighlight Nimlang="nim">import sequtils, strutils
 
func isPrime(n: Positive): bool =
Line 666 ⟶ 815:
for _ in primesOneOdd(1_000_000):
inc count
echo "\nFound $# primes with only one odd digit below 1_000_000.".format(count)</langsyntaxhighlight>
 
{{out}}
Line 679 ⟶ 828:
 
=={{header|Perl}}==
<langsyntaxhighlight lang="perl">#!/usr/bin/perl
 
use strict;
Line 688 ⟶ 837:
my $million = grep tr/13579// == 1, @{ primes(1e6) };
print "found " . @singleodd .
"\n\n@singleodd\n\nfound $million in 1000000\n" =~ s/.{60}\K /\n/gr;</langsyntaxhighlight>
{{out}}
<pre>
Line 702 ⟶ 851:
=={{header|Phix}}==
Relies on the fact that '0', '1', '2', etc are just as odd/even as 0, 1, 2, etc.
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">oneodddigit</span><span style="color: #0000FF;">(</span><span style="color: #004080;">integer</span> <span style="color: #000000;">n</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">return</span> <span style="color: #7060A8;">sum</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">apply</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">sprint</span><span style="color: #0000FF;">(</span><span style="color: #000000;">n</span><span style="color: #0000FF;">),</span><span style="color: #7060A8;">odd</span><span style="color: #0000FF;">))=</span><span style="color: #000000;">1</span> <span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #004080;">sequence</span> <span style="color: #000000;">res</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">filter</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">get_primes_le</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1_000</span><span style="color: #0000FF;">),</span><span style="color: #000000;">oneodddigit</span><span style="color: #0000FF;">)</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;">"Found %d one odd digit primes &lt; 1,000: %V\n"</span><span style="color: #0000FF;">,{</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">res</span><span style="color: #0000FF;">),</span><span style="color: #7060A8;">shorten</span><span style="color: #0000FF;">(</span><span style="color: #000000;">res</span><span style="color: #0000FF;">,</span><span style="color: #008000;">""</span><span style="color: #0000FF;">,</span><span style="color: #000000;">5</span><span style="color: #0000FF;">)})</span>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 715 ⟶ 864:
Fast skip from 11 direct to 20+, from 101 direct to 200+, etc. Around forty times faster than the above would be, but less than twice as fast as it would be without such skipping.<br>
Of course the last digit must/will be odd for all primes (other than 2 which has no odd digit anyway), and ''all'' digits prior to that must be even, eg 223 or 241, and not 257 or 743.
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">m</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #008080;">iff</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">platform</span><span style="color: #0000FF;">()=</span><span style="color: #004600;">JS</span><span style="color: #0000FF;">?</span><span style="color: #000000;">8</span><span style="color: #0000FF;">:</span><span style="color: #000000;">9</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">do</span>
Line 740 ⟶ 889:
<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;">"Found %,d one odd digit primes &lt; %,d\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">count</span><span style="color: #0000FF;">,</span><span style="color: #000000;">m10</span><span style="color: #0000FF;">})</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 752 ⟶ 901:
Found 46,708 one odd digit primes < 100,000,000
Found 202,635 one odd digit primes < 1,000,000,000
</pre>
 
=={{header|Quackery}}==
<code>isprime</code> is defined at [[Primality by trial division#Quackery]].
 
<code>evendigits</code> returns the nth number which has only even digits and ends with zero. There are self-evidently 5^5 of them less than 1000000.
 
We know that the only prime ending with a 5 is 5. So we can omit generating candidate numbers that end with a 5, and stuff the 5 into the right place in the nest (i.e. as item #1; item #0 will be 3) afterwards. This explains the lines <code>' [ 1 3 7 9 ] witheach</code> and <code>5 swap 1 stuff</code>.
 
<syntaxhighlight lang="Quackery"> [ [] swap
[ 5 /mod
rot join swap
dup 0 = until ]
drop
0 swap witheach
[ swap 10 * + ]
20 * ] is evendigits ( n --> n )
 
[]
5 5 ** times
[ i^ evendigits
' [ 1 3 7 9 ] witheach
[ over +
dup isprime iff
[ swap dip join ]
else drop ]
drop ]
5 swap 1 stuff
dup say "Qualifying primes < 1000:"
dup findwith [ 999 > ] [ ]
split drop unbuild
1 split nip -1 split drop
nest$ 44 wrap$ cr cr
say "Number of qualifying primes < 1000000: "
size echo</syntaxhighlight>
 
{{out}}
 
<pre>Qualifying primes < 1000:
3 5 7 23 29 41 43 47 61 67 83 89 223 227 229
241 263 269 281 283 401 409 421 443 449 461
463 467 487 601 607 641 643 647 661 683 809
821 823 827 829 863 881 883 887
 
Number of qualifying primes < 1000000: 2560
</pre>
 
=={{header|Raku}}==
<syntaxhighlight lang="raku" perl6line>put display ^1000 .grep: { ($_ % 2) && .is-prime && (.comb[^(*-1)].all %% 2) }
 
sub display ($list, :$cols = 10, :$fmt = '%6d', :$title = "{+$list} matching:\n" ) {
cache $list;
$title ~ $list.batch($cols)».fmt($fmt).join: "\n"
}</langsyntaxhighlight>
{{out}}
<pre>45 matching:
Line 770 ⟶ 964:
 
=={{header|REXX}}==
<langsyntaxhighlight lang="rexx">/*REXX pgm finds & displays primes (base ten) that contain only one odd digit (< 1,000).*/
parse arg hi cols . /*obtain optional argument from the CL.*/
if hi=='' | hi=="," then hi= 1000 /*Not specified? Then use the default.*/
Line 814 ⟶ 1,008:
end /*k*/ /* [↑] only process numbers ≤ √ J */
#= #+1; @.#= j; sq.#= j*j /*bump # of Ps; assign next P; P square*/
end /*j*/; return</langsyntaxhighlight>
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
Line 835 ⟶ 1,029:
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
load "stdlib.ring"
see "working..." + nl
Line 844 ⟶ 1,038:
odd = 0
str = string(n)
for m = 1 to len(str)
if number(str[m])%2 = 1
odd++
Line 860 ⟶ 1,054:
see "Found " + row + " prime numbers" + nl
see "done..." + nl
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 876 ⟶ 1,070:
Found 45 prime numbers
done...
</pre>
 
=={{header|RPL}}==
{{works with|HP|49g}}
→STR 0
1 3 PICK SIZE '''FOR''' j
OVER j DUP SUB NUM 2 MOD + '''NEXT'''
NIP
≫ ≫ '<span style="color:blue>ODDCNT</span>' STO
{ } 1
'''DO'''
NEXTPRIME
'''IF''' DUP <span style="color:blue>ODDCNT</span> 1 == '''THEN''' SWAP OVER + SWAP '''END'''
'''UNTIL''' DUP 1000 ≥ '''END'''
DROP
≫ ≫ '<span style="color:blue>TASK</span>' STO
{{out}}
<pre>
1: {3 5 7 23 29 41 43 47 61 67 83 89 223 227 229 241 263 269 281 283 401 409 421 443 449 461 463 467 487 601 607 641 643 647 661 683 809 821 823 827 829 863 881 883 887}
</pre>
 
=={{header|Ruby}}==
<syntaxhighlight lang="ruby">require 'prime'
 
def single_odd?(pr)
d = pr.digits
d.first.odd? && d[1..].all?(&:even?)
end
 
res = Prime.each(1000).select {|pr| single_odd?(pr)}
res.each_slice(10){|s| puts "%4d"*s.size % s}
 
n = 1_000_000
count = Prime.each(n).count{|pr| single_odd?(pr)}
puts "\nFound #{count} single-odd-digit primes upto #{n}."
</syntaxhighlight>
{{out}}
<pre> 3 5 7 23 29 41 43 47 61 67
83 89 223 227 229 241 263 269 281 283
401 409 421 443 449 461 463 467 487 601
607 641 643 647 661 683 809 821 823 827
829 863 881 883 887
 
Found 2560 single-odd-digit primes upto 1000000.
</pre>
 
=={{header|Sidef}}==
<langsyntaxhighlight lang="ruby">func primes_with_one_odd_digit(upto, base = 10) {
 
upto = prev_prime(upto+1)
Line 916 ⟶ 1,157:
var count = primes_with_one_odd_digit(10**k).len
say "There are #{'%6s' % count.commify} such primes <= 10^#{k}"
}</langsyntaxhighlight>
{{out}}
<pre>
Line 939 ⟶ 1,180:
{{libheader|Wren-math}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="wren">import "./math" for Int
{{libheader|Wren-seq}}
<lang ecmascript>import "./math" for Int
import "./fmt" for Fmt
 
import "./seq" for Lst
var limit = 999
var maxDigits = 3
Line 952 ⟶ 1,191:
}
Fmt.print("Primes under $,d which contain only one odd digit:", limit + 1)
for (chunk in Lst.chunks(results, 9)) Fmt.printtprint("$,%(maxDigits)d", chunkresults, 9)
System.print("\nFound %(results.count) such primes.\n")
 
limit = 1e9 - 1
primes = Int.primeSieve(limit)
Line 966 ⟶ 1,205:
}
}
Fmt.print("There are $,7d such primes under $,d", count, pow)</langsyntaxhighlight>
 
{{out}}
Line 991 ⟶ 1,230:
 
=={{header|XPL0}}==
<langsyntaxhighlight XPL0lang="xpl0">func IsPrime(N); \Return 'true' if N is a prime number
int N, I;
[if N <= 1 then return false;
Line 1,015 ⟶ 1,254:
Text(0, " such numbers found.
");
]</langsyntaxhighlight>
 
{{out}}
9,476

edits