Prime numbers which contain 123: Difference between revisions

Content added Content deleted
(Add CLU)
(Prime numbers which contain 123 in BASIC256)
Line 139: Line 139:
Primes with '123' 1-999999: 451
Primes with '123' 1-999999: 451
</pre>
</pre>

=={{header|BASIC256}}==
<lang BASIC256>global columna
print "Prime numbers which contain 123"
print
limite = 100000
call prime(limite, true)
print : print
print "Found "; columna; " prime numbers below "; limite
limite = 1e6
call prime(limite, false)
print : print
print "Found "; columna; " prime numbers below "; int(limite)
end

function isPrime(v)
if v < 2 then return False
if v mod 2 = 0 then return v = 2
if v mod 3 = 0 then return v = 3
d = 5
while d * d <= v
if v mod d = 0 then return False else d += 2
end while
return True
end function

subroutine prime(limite, mostrar)
columna = 0

for n = 1 to limite
strn$ = string(n)
if isPrime(n) and instr(strn$, "123") > 0 then
columna += 1
if mostrar then
print rjust(string(n), 7);
if columna mod 8 = 0 then print
end if
endif
next n
end subroutine</lang>
{{out}}
<pre>Same as FreeBASIC entry.</pre>


=={{header|CLU}}==
=={{header|CLU}}==