Blum integer: Difference between revisions

m
→‎{{header|Phix}}: use pygments
(→‎{{header|RPL}}: comment on the FACTORS command)
m (→‎{{header|Phix}}: use pygments)
 
(18 intermediate revisions by 10 users not shown)
Line 139:
24.985% end with 9
</pre>
 
=={{header|BASIC}}==
==={{header|BASIC256}}===
{{trans|FreeBASIC}}
<syntaxhighlight lang="vb">global Prime1
n = 3
c = 0
 
print "The first 50 Blum integers:"
while True
if isSemiprime(n) then
if Prime1 % 4 = 3 then
Prime2 = n / Prime1
if (Prime2 <> Prime1) and (Prime2 % 4 = 3) then
c += 1
if c <= 50 then
print rjust(string(n), 4);
if c % 10 = 0 then print
end if
if c >= 26828 then
print : print "The 26828th Blum integer is: "; n
exit while
end if
end if
end if
end if
n += 2
end while
end
 
function isSemiprime(n)
d = 3
c = 0
while d*d <= n
while n % d = 0
if c = 2 then return false
n /= d
c += 1
end while
d += 2
end while
Prime1 = n
return c = 1
end function</syntaxhighlight>
 
==={{header|FreeBASIC}}===
<syntaxhighlight lang="vb">Dim Shared As Uinteger Prime1
Dim As Uinteger n = 3, c = 0, Prime2
 
Function isSemiprime(n As Uinteger) As Boolean
Dim As Uinteger d = 3, c = 0
While d*d <= n
While n Mod d = 0
If c = 2 Then Return False
n /= d
c += 1
Wend
d += 2
Wend
Prime1 = n
Return c = 1
End Function
 
Print "The first 50 Blum integers:"
Do
If isSemiprime(n) Then
If Prime1 Mod 4 = 3 Then
Prime2 = n / Prime1
If (Prime2 <> Prime1) And (Prime2 Mod 4 = 3) Then
c += 1
If c <= 50 Then
Print Using "####"; n;
If c Mod 10 = 0 Then Print
End If
If c >= 26828 Then
Print !"\nThe 26828th Blum integer is: " ; n
Exit Do
End If
End If
End If
End If
n += 2
Loop
 
Sleep</syntaxhighlight>
{{out}}
<pre>The first 50 Blum integers:
21 33 57 69 77 93 129 133 141 161
177 201 209 213 217 237 249 253 301 309
321 329 341 381 393 413 417 437 453 469
473 489 497 501 517 537 553 573 581 589
597 633 649 669 681 713 717 721 737 749
 
The 26828th Blum integer is: 524273</pre>
 
==={{header|Gambas}}===
{{trans|FreeBASIC}}
<syntaxhighlight lang="vbnet">Public Prime1 As Integer
 
Public Sub Main()
Dim n As Integer = 3, c As Integer = 0, Prime2 As Integer
Print "The first 50 Blum integers:"
Do
If isSemiprime(n) Then
If Prime1 Mod 4 = 3 Then
Prime2 = n / Prime1
If (Prime2 <> Prime1) And (Prime2 Mod 4 = 3) Then
c += 1
If c <= 50 Then
Print Format$(n, "####");
If c Mod 10 = 0 Then Print
End If
If c >= 26828 Then
Print "\nThe 26828th Blum integer is: "; n
Break
End If
End If
End If
End If
n += 2
Loop
 
End
 
Function isSemiprime(n As Integer) As Boolean
 
Dim d As Integer = 3, c As Integer = 0
While d * d <= n
While n Mod d = 0
If c = 2 Then Return False
n /= d
c += 1
Wend
d += 2
Wend
Prime1 = n
Return c = 1
 
End Function </syntaxhighlight>
 
=={{header|C}}==
Line 219 ⟶ 360:
</pre>
 
=={{header|FreeBASIC}}==
<syntaxhighlight lang="vb">Dim Shared As Uinteger Prime1
Dim As Uinteger n = 3, c = 0, Prime2
 
=={{header|C#}}==
Function isSemiprime(n As Uinteger) As Boolean
{{trans|Java}}
Dim As Uinteger d = 3, c = 0
<syntaxhighlight lang="C#">
While d*d <= n
using System;
While n Mod d = 0
using System.Collections.Generic;
If c = 2 Then Return False
n /= d
c += 1
Wend
d += 2
Wend
Prime1 = n
Return c = 1
End Function
 
public class BlumInteger
Print "The first 50 Blum integers:"
{
Do
public static void Main(string[] args)
If isSemiprime(n) Then
{
If Prime1 Mod 4 = 3 Then
int[] Prime2blums = n /new Prime1int[50];
int blumCount = 0;
If (Prime2 <> Prime1) And (Prime2 Mod 4 = 3) Then
Dictionary<int, int> lastDigitCounts = new Dictionary<int, int>();
c += 1
int number If c <= 50 Then1;
Print Using "####"; n;
If c Mod 10 = 0 Then Print
End If
If c >= 26828 Then
Print !"\nThe 26828th Blum integer is: " ; n
Exit Do
End If
End If
End If
End If
n += 2
Loop
 
while (blumCount < 400000)
Sleep</syntaxhighlight>
{
int prime = LeastPrimeFactor(number);
if (prime % 4 == 3)
{
int quotient = number / prime;
if (quotient != prime && IsPrimeType3(quotient))
{
if (blumCount < 50)
{
blums[blumCount] = number;
}
 
if (!lastDigitCounts.ContainsKey(number % 10))
{
lastDigitCounts[number % 10] = 0;
}
lastDigitCounts[number % 10]++;
 
blumCount++;
if (blumCount == 50)
{
Console.WriteLine("The first 50 Blum integers:");
for (int i = 0; i < 50; i++)
{
Console.Write($"{blums[i],3}");
Console.Write((i % 10 == 9) ? Environment.NewLine : " ");
}
Console.WriteLine();
}
else if (blumCount == 26828 || blumCount % 100000 == 0)
{
Console.WriteLine($"The {blumCount}th Blum integer is: {number}");
if (blumCount == 400000)
{
Console.WriteLine();
Console.WriteLine("Percent distribution of the first 400000 Blum integers:");
foreach (var key in lastDigitCounts.Keys)
{
Console.WriteLine($" {((double)lastDigitCounts[key] / 4000):0.000}% end in {key}");
}
}
}
}
}
number += (number % 5 == 3) ? 4 : 2;
}
}
 
private static bool IsPrimeType3(int number)
{
if (number < 2) return false;
if (number % 2 == 0) return number == 2;
if (number % 3 == 0) return number == 3;
 
for (int divisor = 5; divisor * divisor <= number; divisor += 2)
{
if (number % divisor == 0) return false;
}
return number % 4 == 3;
}
 
private static int LeastPrimeFactor(int number)
{
if (number == 1) return 1;
if (number % 2 == 0) return 2;
if (number % 3 == 0) return 3;
if (number % 5 == 0) return 5;
 
for (int divisor = 7; divisor * divisor <= number; divisor += 2)
{
if (number % divisor == 0) return divisor;
}
return number;
}
}
</syntaxhighlight>
{{out}}
<pre>
<pre>The first 50 Blum integers:
The first 50 Blum integers:
21 33 57 69 77 93 129 133 141 161
21 33 57 69 77 93 129 133 141 161
177 201 209 213 217 237 249 253 301 309
321177 329201 341209 381213 393217 413237 417249 437253 453301 469309
473321 489329 497341 501381 517393 537413 553417 573437 581453 589469
597473 633489 649497 669501 681517 713537 717553 721573 737581 749589
597 633 649 669 681 713 717 721 737 749
 
The 26828th Blum integer is: 524273</pre>
The 100000th Blum integer is: 2075217
The 200000th Blum integer is: 4275533
The 300000th Blum integer is: 6521629
The 400000th Blum integer is: 8802377
 
Percent distribution of the first 400000 Blum integers:
25.001% end in 1
25.017% end in 3
24.997% end in 7
24.985% end in 9
 
</pre>
 
 
=={{header|C++}}==
<syntaxhighlight lang="java">
 
#include <algorithm>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <vector>
 
bool is_prime_type_3(const int32_t number) {
if ( number < 2 ) return false;
if ( number % 2 == 0 ) return false;
if ( number % 3 == 0 ) return number == 3;
 
for ( int divisor = 5; divisor * divisor <= number; divisor += 2 ) {
if ( number % divisor == 0 ) { return false; }
}
 
return number % 4 == 3;
}
 
int32_t least_prime_factor(const int32_t number) {
if ( number == 1 ) { return 1; }
if ( number % 3 == 0 ) { return 3; }
if ( number % 5 == 0 ) { return 5; }
 
for ( int divisor = 7; divisor * divisor <= number; divisor += 2 ) {
if ( number % divisor == 0 ) { return divisor; }
}
 
return number;
}
 
int main() {
int32_t blums[50];
int32_t blum_count = 0;
int32_t last_digit_counts[10] = {};
int32_t number = 1;
 
while ( blum_count < 400'000 ) {
const int32_t prime = least_prime_factor(number);
if ( prime % 4 == 3 ) {
const int32_t quotient = number / prime;
if ( quotient != prime && is_prime_type_3(quotient) ) {
if ( blum_count < 50 ) {
blums[blum_count] = number;
}
last_digit_counts[number % 10] += 1;
blum_count += 1;
if ( blum_count == 50 ) {
std::cout << "The first 50 Blum integers:" << std::endl;
for ( int32_t i = 0; i < 50; ++i ) {
std::cout << std::setw(3) << blums[i] << ( ( i % 10 == 9 ) ? "\n" : " " );
}
std::cout << std::endl;
} else if ( blum_count == 26'828 || blum_count % 100'000 == 0 ) {
std::cout << "The " << std::setw(6) << blum_count << "th Blum integer is: "
<< std::setw(7) << number << std::endl;
if ( blum_count == 400'000 ) {
std::cout << "\nPercent distribution of the first 400000 Blum integers:" << std::endl;
for ( const int32_t& i : { 1, 3, 7, 9 } ) {
std::cout << " " << std::setw(6) << std::setprecision(5)
<< (double) last_digit_counts[i] / 4'000 << "% end in " << i << std::endl;
}
}
}
}
}
number += ( number % 5 == 3 ) ? 4 : 2;
}
}
</syntaxhighlight>
{{ out }}
<pre>
The first 50 Blum integers:
21 33 57 69 77 93 129 133 141 161
177 201 209 213 217 237 249 253 301 309
321 329 341 381 393 413 417 437 453 469
473 489 497 501 517 537 553 573 581 589
597 633 649 669 681 713 717 721 737 749
 
The 26828th Blum integer is: 524273
The 100000th Blum integer is: 2075217
The 200000th Blum integer is: 4275533
The 300000th Blum integer is: 6521629
The 400000th Blum integer is: 8802377
 
Percent distribution of the first 400000 Blum integers:
25.001% end in 1
25.017% end in 3
24.997% end in 7
24.985% end in 9
</pre>
 
=={{header|EasyLang}}==
{{trans|FreeBASIC}}
<syntaxhighlight lang=easylang>fastfunc semiprim n .
d = 3
while d * d <= n
while n mod d = 0
if c = 2
return 0
.
n /= d
c += 1
.
d += 2
.
if c = 1
return n
.
.
print "The first 50 Blum integers:"
n = 3
numfmt 0 4
repeat
prim1 = semiprim n
if prim1 <> 0
if prim1 mod 4 = 3
prim2 = n div prim1
if prim2 <> prim1 and prim2 mod 4 = 3
c += 1
if c <= 50
write n
if c mod 10 = 0 ; print "" ; .
.
.
.
.
until c >= 26828
n += 2
.
print ""
print "The 26828th Blum integer is: " & n</syntaxhighlight>
 
=={{header|Go}}==
Line 346 ⟶ 689:
<pre>
Same as Wren example.
</pre>
 
=={{header|Haskell}}==
Works with <code>GHC 9.2.8</code> and [https://hackage.haskell.org/package/arithmoi-0.13.0.0 arithmoi-0.13.0.0].
<syntaxhighlight lang="haskell">
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE ScopedTypeVariables #-}
 
module Rosetta.BlumInteger
( Stream (..)
, Stats (..)
, toList
, blumIntegers
, countLastDigits
) where
 
import GHC.Natural (Natural)
import Math.NumberTheory.Primes (Prime (..), nextPrime)
 
-- | A stream is an infinite list.
data Stream a = a :> Stream a
deriving Functor
 
-- | Converts a stream to the corresponding infinite list.
toList :: Stream a -> [a]
toList (x :> xs) = x : toList xs
 
unsafeFromList :: [a] -> Stream a
unsafeFromList = foldr (:>) $ error "fromList: finite list"
 
primes3mod4 :: Stream (Prime Natural)
primes3mod4 = unsafeFromList [nextPrime 3, nextPrime 7 ..]
 
-- Assume:
-- * All numbers in all the streams are distinct.
-- * Each stream is sorted.
-- * In the stream of streams, the first element of each stream is less than the first element of the next stream.
sortStreams :: forall a. Ord a => Stream (Stream a) -> Stream a
sortStreams ((x :> xs) :> xss) = x :> sortStreams (insert xs xss)
where
insert :: Stream a -> Stream (Stream a) -> Stream (Stream a)
insert ys@(y :> _) zss@(zs@(z :> _) :> zss')
| y < z = ys :> zss
| otherwise = zs :> insert ys zss'
 
-- | The
blumIntegers :: Stream Natural
blumIntegers = sortStreams $ go $ unPrime <$> primes3mod4
where
go :: Stream Natural -> Stream (Stream Natural)
go (p :> ps) = ((p *) <$> ps) :> go ps
 
data Stats a = Stats
{ s1 :: !a
, s3 :: !a
, s7 :: !a
, s9 :: !a
} deriving (Show, Eq, Ord, Functor)
 
lastDigit :: Natural -> Int
lastDigit n = fromIntegral $ n `mod` 10
 
updateCount :: Stats Int -> Natural -> Stats Int
updateCount !dc n = case lastDigit n of
1 -> dc { s1 = s1 dc + 1 }
3 -> dc { s3 = s3 dc + 1 }
7 -> dc { s7 = s7 dc + 1 }
9 -> dc { s9 = s9 dc + 1 }
_ -> error "updateCount: impossible"
 
countLastDigits :: forall a. Fractional a => Int -> Stream Natural -> Stats a
countLastDigits n = fmap f . go Stats { s1 = 0, s3 = 0, s7 = 0, s9 = 0 } n
where
go :: Stats Int -> Int -> Stream Natural -> Stats Int
go !dc 0 _ = dc
go !dc m (x :> xs) = go (updateCount dc x) (m - 1) xs
 
f :: Int -> a
f m = fromIntegral m / fromIntegral n
 
 
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE TypeApplications #-}
 
module Main
( main
) where
 
import Control.Monad (forM_)
import Text.Printf (printf)
 
import Numeric.Natural (Natural)
 
import Rosetta.BlumInteger
 
main :: IO ()
main = do
let xs = toList blumIntegers
 
printf "The first 50 Blum integers are:\n\n"
forM_ (take 50 xs) $ \x -> do
printf "%3d\n" x
printf "\n"
 
nth xs 26_828
forM_ [100_000, 200_000 .. 400_000] $ nth xs
printf "\n"
 
printf "Distribution by final digit for the first 400000 Blum integers:\n\n"
let Stats r1 r3 r7 r9 = countLastDigits @Double 400_000 blumIntegers
forM_ [(1 :: Int, r1), (3, r3), (7, r7), (9, r9)] $ \(d, r) ->
printf "%d: %6.3f%%\n" d $ r * 100
printf "\n"
 
where
 
nth :: [Natural] -> Int -> IO ()
nth xs n = printf "The %6dth Blum integer is %8d.\n" n $ xs !! (n - 1)
</syntaxhighlight>
 
{{out}}
<pre>
The first 50 Blum integers are:
 
21
33
57
69
77
93
129
133
141
161
177
201
209
213
217
237
249
253
301
309
321
329
341
381
393
413
417
437
453
469
473
489
497
501
517
537
553
573
581
589
597
633
649
669
681
713
717
721
737
749
 
The 26828th Blum integer is 524273.
The 100000th Blum integer is 2075217.
The 200000th Blum integer is 4275533.
The 300000th Blum integer is 6521629.
The 400000th Blum integer is 8802377.
 
Distribution by final digit for the first 400000 Blum integers:
 
1: 25.001%
3: 25.017%
7: 24.997%
9: 24.985%
</pre>
 
Line 401 ⟶ 932:
=={{header|Java}}==
<syntaxhighlight lang="java">
 
import java.util.ArrayList;
import java.util.BitSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
Line 410 ⟶ 939:
 
public static void main(String[] aArgs) {
final int limit = 10_000_000;
List<Integer> primeNumbersType3 = primeNumbersType3(limit);
int[] leastPrimeFactors = leastPrimeFactors(limit);
int[] blums = new int[50];
int blumCount = 0;
Line 420 ⟶ 945:
while ( blumCount < 400_000 ) {
final int prime = leastPrimeFactors[leastPrimeFactor(number]);
if ( ( prime & 3% )4 == 3 ) {
final int quotient = number / prime;
if ( quotient != prime && primeNumbersType3.containsisPrimeType3(quotient) ) {
if ( blumCount < 50 ) {
blums[blumCount] = number;
Line 450 ⟶ 975:
}
}
number += ( number % 5 == 3 ) ? number + 4 : number + 2;
}
}
private static int[] leastPrimeFactors(int aLimit) {
int[] result = new int[aLimit + 1];
for ( int i = 2; i * i <= aLimit; i++ ) {
if ( result[i] == 0 ) {
for ( int k = i * i; k <= aLimit; k += i ) {
if ( result[k] == 0 ) {
result[k] = i;
}
}
}
}
for ( int i = 1; i <= aLimit; i++ ) {
if ( result[i] == 0 ) {
result[i] = i;
}
}
return result;
}
private static List<Integer>boolean primeNumbersType3isPrimeType3(int aLimitaNumber) {
if ( aNumber < 2 ) { return false; }
BitSet sieve = new BitSet(aLimit + 1);
if ( aNumber % 2 == 0 ) { return false; }
sieve.set(2, aLimit + 1);
if ( aNumber % 3 == 0 ) { return aNumber == 3; }
for ( int i = 2; i <= (int) Math.sqrt(aLimit); i = sieve.nextSetBit(i + 1) ) {
 
for ( int j = i * i; j <= aLimit; j = j + i ) {
for ( int divisor = 5; divisor * divisor <= aNumber; divisor += 2 ) {
sieve.clear(j);
if ( aNumber % divisor == 0 ) { return false; }
}
}
List<Integer> primesType3 = new ArrayList<Integer>();
for ( int i = 2; i >= 0; i = sieve.nextSetBit(i + 1) ) {
if ( i % 4 == 3 ) {
primesType3.add(i);
}
}
return primesType3aNumber % 4 == 3;
}
 
private static int leastPrimeFactor(int aNumber) {
if ( aNumber == 1 ) { return 1; }
if ( aNumber % 3 == 0 ) { return 3; }
if ( aNumber % 5 == 0 ) { return 5; }
for ( int divisor = 7; divisor * divisor <= aNumber; divisor += 2 ) {
if ( aNumber % divisor == 0 ) { return divisor; }
}
return aNumber;
}
 
}
Line 672 ⟶ 1,181:
end
</syntaxhighlight>{{out}} Same as Wren, Go, etc
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<syntaxhighlight lang="mathematica">
 
ClearAll[BlumIntegerQ, BlumIntegersInRange, PrimePi2, BlumCount, binarySearch, BlumInts, timing, upperLimitEstimate, lastDigit, lastDigitDistributionPercents];
 
BlumIntegerQ[n_Integer] := With[{factors = FactorInteger[n]},
n ~ Mod ~ 4 == 1 &&
Length[factors] == 2 &&
factors[[1, 1]] ~ Mod ~ 4 == 3 &&
Last@Total@factors == 2
];
SetAttributes[BlumIntegerQ, Listable];
 
BlumIntegersInRange[n_Integer] := BlumIntegersInRange[1, n];
BlumIntegersInRange[start_Integer, end_Integer] :=
Select[Range[start + (4 - start) ~ Mod ~ 4, end, 4] + 1, BlumIntegerQ];
 
(* Counts semiprimes. See https://people.maths.ox.ac.uk/erban/papers/paperDCRE.pdf *)
 
PrimePi2[x_] := (PrimePi[Sqrt[x]] - PrimePi[Sqrt[x]]^2)/2 + Sum[PrimePi[x/Prime[p]], {p, 1, PrimePi[Sqrt[x]]}];
SetAttributes[PrimePi2, Listable];
 
(* Blum integers are semiprimes that are 1 mod 4, with two distinct factors where both factors are 3 mod 4. The following function gives an approximation of the number of Blum integers <= x.
 
According to my tests, this function tends to overestimate by approximately 5% in the range we're interested in.
*)
 
BlumCount[x_] := Ceiling[(PrimePi2[x] - PrimePi[Sqrt[x]]) / 4];
SetAttributes[BlumCount, Listable];
 
binarySearch[f_, targetValue_] :=
Module[{lo = 1, mid, hi = 1, currentValue},
While[f[hi] < targetValue,
hi *= 2;];
While[lo <= hi,
mid = Ceiling[(lo + hi) / 2];
currentValue = f[mid];
If[currentValue < targetValue,
lo = mid + 1;];
If[currentValue > targetValue,
hi = mid - 1;];
If[currentValue == targetValue,
While[f[mid] == targetValue,
mid++;
];
Return[mid - 1];
];
];
];
 
lastDigit[n_Integer] := n ~ Mod ~ 10;
SetAttributes[lastDigit, Listable];
 
upperLimitEstimate = Ceiling[binarySearch[BlumCount, 400000]* 1.1];
timing = First@AbsoluteTiming[BlumInts = BlumIntegersInRange[upperLimitEstimate];];
lastDigitDistributionPercents = N[Counts@lastDigit@BlumInts[[;; 400000]] / 4000, 5];
 
Print["Calculated the first ", Length[BlumInts],
" Blum integers in ", timing, " seconds."];
Print[];
Print["First 50 Blum integers:"];
Print[TableForm[Partition[BlumInts[[;; 50]], 10],
TableAlignments -> Right]];
Print[];
Print[Grid[
Table[{"The ", n , "th Blum integer is: ",
BlumInts[[n]]}, {n, {26828, 100000, 200000, 300000, 400000}}] ,
Alignment -> Right]]
Print[];
Print["% distribution of the first 400,000 Blum integers:"];
Print[Grid[
Table[{lastDigitDistributionPercents[n], "% end in ",
n}, {n, {1, 3, 7, 9}} ], Alignment -> Right]];
 
</syntaxhighlight>
 
{{out}}
 
<pre>
Calculated the first 416420 Blum integers in 15.1913 seconds.
 
First 50 Blum integers:
21 33 57 69 77 93 129 133 141 161
177 201 209 213 217 237 249 253 301 309
321 329 341 381 393 413 417 437 453 469
473 489 497 501 517 537 553 573 581 589
597 633 649 669 681 713 717 721 737 749
 
The 26828 th Blum integer is: 524273
The 100000 th Blum integer is: 2075217
The 200000 th Blum integer is: 4275533
The 300000 th Blum integer is: 6521629
The 400000 th Blum integer is: 8802377
 
% distribution of the first 400,000 Blum integers:
25.001% end in 1
25.017% end in 3
24.997% end in 7
24.985% end in 9
</pre>
 
=={{header|Maxima}}==
<syntaxhighlight lang="maxima">
/* Predicate functions that checks wether an integer is a Blum integer or not */
blum_p(n):=lambda([x],length(ifactors(x))=2 and unique(map(second,ifactors(x)))=[1] and mod(ifactors(x)[1][1],4)=3 and mod(ifactors(x)[2][1],4)=3)(n)$
 
/* Function that returns a list of the first len Blum integers */
blum_count(len):=block(
[i:1,count:0,result:[]],
while count<len do (if blum_p(i) then (result:endcons(i,result),count:count+1),i:i+1),
result)$
 
/* Test cases */
/* First 50 Blum integers */
blum_count(50);
 
/* Blum integer number 26828 */
last(blum_count(26828));
</syntaxhighlight>
{{out}}
<pre>
[21,33,57,69,77,93,129,133,141,161,177,201,209,213,217,237,249,253,301,309,321,329,341,381,393,413,417,437,453,469,473,489,497,501,517,537,553,573,581,589,597,633,649,669,681,713,717,721,737,749]
 
524273
</pre>
 
=={{header|Nim}}==
Line 950 ⟶ 1,585:
{{trans|Raku}}
{{libheader|ntheory}}
<syntaxhighlight lang="perl" line>use v5.36;
use ntheory qw(is_square is_semiprime factor vecall);
use v5.36;
use enum <false true>;
use ntheory <is_prime gcd>;
 
sub comma { reverse ((reverse shift) =~ s/.{3}\K/,/gr) =~ s/^,//r }
sub table ($c, @V) { my $t = $c * (my $w = 5); ( sprintf( ('%' . $w . 'd') x @V, @V) ) =~ s/.{1,$t}\K/\n/gr }
 
sub is_blum ($n) {
($n % 4) == 1 && is_semiprime($n) && !is_square($n) && vecall { ($_ % 4) == 3 } factor($n);
return false if $n < 2 or is_prime $n;
my $factor = find_factor($n);
my $div = int($n / $factor);
return true if is_prime($factor) && is_prime($div) && ($div != $factor) && ($factor%4 == 3) && ($div%4 == 3);
false;
}
 
sub find_factor ($n, $constant = 1) {
my($x, $rho, $factor) = (2, 1, 1);
while ($factor == 1) {
$rho *= 2;
my $fixed = $x;
for (0..$rho) {
$x = ( $x * $x + $constant ) % $n;
$factor = gcd(($x-$fixed), $n);
last if 1 < $factor;
}
}
$factor = find_factor($n, $constant+1) if $n == $factor;
$factor;
}
 
my($i, @blum, %C);
my @nth = (26828, 1e5, 2e5, 3e5, 4e5);
 
my (@blum, %C);
while (++$i) {
for (my $i = 1 ; ; ++$i) {
push @blum, $i if is_blum $i;
last if $nth[-1] == scalar @blum;
}
$C{substr $_, -1,% 110}++ for @blum;
 
say "The first fifty Blum integers:\n" . table 10, @blum[0 .. 49];
printf "The %7sth Blum integer: %9s\n", comma($_), comma $blum[$_ - 1] for @nth;
say '';
printf "$_: %6d (%.3f%%)\n", $C{$_}, 100 * $C{$_} / scalar @blum for <1 3 7 9>;</syntaxhighlight>
 
</syntaxhighlight>
{{out}}
<pre>
Line 1,020 ⟶ 1,632:
{{trans|Pascal}}
You can run this online [http://phix.x10.mx/p2js/Blum.htm here].
<!--<syntaxhighlight lang="phix">(phixonline)-->
<syntaxhighlight lang="phix">
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
with javascript_semantics
<span style="color: #008080;">constant</span> <span style="color: #000000;">LIMIT</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1e7</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">N</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">floor</span><span style="color: #0000FF;">((</span><span style="color: #7060A8;">floor</span><span style="color: #0000FF;">(</span><span style="color: #000000;">LIMIT</span><span style="color: #0000FF;">/</span><span style="color: #000000;">3</span><span style="color: #0000FF;">)-</span><span style="color: #000000;">1</span><span style="color: #0000FF;">)/</span><span style="color: #000000;">4</span><span style="color: #0000FF;">)+</span><span style="color: #000000;">1</span>
constant LIMIT = 1e7, N = floor((floor(LIMIT/3)-1)/4)+1
 
<span style="color: #008080;">function</span> <span style="color: #000000;">Sieve4n_3_Primes</span><span style="color: #0000FF;">()</span>
function Sieve4n_3_Primes()
<span style="color: #004080;">sequence</span> <span style="color: #000000;">sieve</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">N</span><span style="color: #0000FF;">),</span> <span style="color: #000000;">p4n3</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{}</span>
sequence sieve = repeat(0,N), p4n3 = {}
<span style="color: #008080;">for</span> <span style="color: #000000;">idx</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #000000;">N</span> <span style="color: #008080;">do</span>
for idx=1 to N do
<span style="color: #008080;">if</span> <span style="color: #000000;">sieve</span><span style="color: #0000FF;">[</span><span style="color: #000000;">idx</span><span style="color: #0000FF;">]=</span><span style="color: #000000;">0</span> <span style="color: #008080;">then</span>
if sieve[idx]=0 then
<span style="color: #004080;">integer</span> <span style="color: #000000;">n</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">idx</span><span style="color: #0000FF;">*</span><span style="color: #000000;">4</span><span style="color: #0000FF;">-</span><span style="color: #000000;">1</span>
integer n = idx*4-1
<span style="color: #000000;">p4n3</span> <span style="color: #0000FF;">&=</span> <span style="color: #000000;">n</span>
p4n3 &= n
<span style="color: #008080;">if</span> <span style="color: #000000;">idx</span><span style="color: #0000FF;">+</span><span style="color: #000000;">n</span><span style="color: #0000FF;">></span><span style="color: #000000;">N</span> <span style="color: #008080;">then</span>
if idx+n>N then
<span style="color: #000080;font-style:italic;">// collect the rest</span>
// collect the rest
<span style="color: #008080;">for</span> <span style="color: #000000;">j</span><span style="color: #0000FF;">=</span><span style="color: #000000;">idx</span><span style="color: #0000FF;">+</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #000000;">N</span> <span style="color: #008080;">do</span>
for j=idx+1 to N do
<span style="color: #008080;">if</span> <span style="color: #000000;">sieve</span><span style="color: #0000FF;">[</span><span style="color: #000000;">j</span><span style="color: #0000FF;">]=</span><span style="color: #000000;">0</span> <span style="color: #008080;">then</span>
if sieve[j]=0 then
<span style="color: #000000;">p4n3</span> <span style="color: #0000FF;">&=</span> <span style="color: #000000;">4</span><span style="color: #0000FF;">*</span><span style="color: #000000;">j</span><span style="color: #0000FF;">-</span><span style="color: #000000;">1</span>
<span style="color: #008080;">end</span> <spanp4n3 style&="color: #008080;">if</span>4*j-1
<span style="color: #008080;"> end</span> <span style="color: #008080;">for</span>if
end <span style="color: #008080;">exit</span>for
exit
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
end if
<span style="color: #008080;">for</span> <span style="color: #000000;">j</span><span style="color: #0000FF;">=</span><span style="color: #000000;">idx</span><span style="color: #0000FF;">+</span><span style="color: #000000;">n</span> <span style="color: #008080;">to</span> <span style="color: #000000;">N</span> <span style="color: #008080;">by</span> <span style="color: #000000;">n</span> <span style="color: #008080;">do</span>
for j=idx+n to N by n do
<span style="color: #000000;">sieve</span><span style="color: #0000FF;">[</span><span style="color: #000000;">j</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1</span>
sieve[j] = 1
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
end for
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
end if
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
end for
<span style="color: #008080;">return</span> <span style="color: #000000;">p4n3</span>
return p4n3
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
end function
 
<span style="color: #004080;">sequence</span> <span style="color: #000000;">p4n3</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">Sieve4n_3_Primes</span><span style="color: #0000FF;">(),</span>
sequence p4n3 = Sieve4n_3_Primes(),
<span style="color: #000000;">BlumField</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #004600;">false</span><span style="color: #0000FF;">,</span><span style="color: #000000;">LIMIT</span><span style="color: #0000FF;">),</span>
BlumField = repeat(false,LIMIT),
<span style="color: #000000;">Blum50</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{},</span> <span style="color: #000000;">counts</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">10</span><span style="color: #0000FF;">)</span>
Blum50 = {}, counts = repeat(0,10)
 
<span style="color: #008080;">for</span> <span style="color: #000000;">idx</span><span style="color: #0000FF;">,</span><span style="color: #000000;">n</span> <span style="color: #008080;">in</span> <span style="color: #000000;">p4n3</span> <span style="color: #008080;">do</span>
for idx,n in p4n3 do
<span style="color: #008080;">for</span> <span style="color: #000000;">bj</span> <span style="color: #008080;">in</span> <span style="color: #000000;">p4n3</span> <span style="color: #008080;">from</span> <span style="color: #000000;">idx</span><span style="color: #0000FF;">+</span><span style="color: #000000;">1</span> <span style="color: #008080;">do</span>
for bj in p4n3 from idx+1 do
<span style="color: #004080;">atom</span> <span style="color: #000000;">k</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">n</span><span style="color: #0000FF;">*</span><span style="color: #000000;">bj</span>
atom k = n*bj
<span style="color: #008080;">if</span> <span style="color: #000000;">k</span><span style="color: #0000FF;">></span><span style="color: #000000;">LIMIT</span> <span style="color: #008080;">then</span> <span style="color: #008080;">exit</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
if k>LIMIT then exit end if
<span style="color: #000000;">BlumField</span><span style="color: #0000FF;">[</span><span style="color: #000000;">k</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">=</span> <span style="color: #004600;">true</span>
BlumField[k] = true
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
end for
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
end for
<span style="color: #004080;">integer</span> <span style="color: #000000;">count</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">0</span>
integer count = 0
<span style="color: #008080;">for</span> <span style="color: #000000;">n</span><span style="color: #0000FF;">,</span><span style="color: #000000;">k</span> <span style="color: #008080;">in</span> <span style="color: #000000;">BlumField</span> <span style="color: #008080;">do</span>
for n,k in BlumField do
<span style="color: #008080;">if</span> <span style="color: #000000;">k</span> <span style="color: #008080;">then</span>
if k then
<span style="color: #008080;">if</span> <span style="color: #000000;">count</span><span style="color: #0000FF;"><</span><span style="color: #000000;">50</span> <span style="color: #008080;">then</span> <span style="color: #000000;">Blum50</span> <span style="color: #0000FF;">&=</span> <span style="color: #000000;">n</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
if count<50 then Blum50 &= n end if
<span style="color: #000000;">counts</span><span style="color: #0000FF;">[</span><span style="color: #7060A8;">remainder</span><span style="color: #0000FF;">(</span><span style="color: #000000;">n</span><span style="color: #0000FF;">,</span><span style="color: #000000;">10</span><span style="color: #0000FF;">)]</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span>
counts[remainder(n,10)] += 1
<span style="color: #000000;">count</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span>
count += 1
<span style="color: #008080;">if</span> <span style="color: #000000;">count</span><span style="color: #0000FF;">=</span><span style="color: #000000;">50</span> <span style="color: #008080;">then</span>
if count=50 then
<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;">"First 50 Blum integers:\n%s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #7060A8;">join_by</span><span style="color: #0000FF;">(</span><span style="color: #000000;">Blum50</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">10</span><span style="color: #0000FF;">,</span><span style="color: #008000;">" "</span><span style="color: #0000FF;">,</span><span style="color: #000000;">fmt</span><span style="color: #0000FF;">:=</span><span style="color: #008000;">"%3d"</span><span style="color: #0000FF;">)})</span>
printf(1,"First 50 Blum integers:\n%s\n",{join_by(Blum50,1,10," ",fmt:="%3d")})
<span style="color: #008080;">elsif</span> <span style="color: #000000;">count</span><span style="color: #0000FF;">=</span><span style="color: #000000;">26828</span> <span style="color: #008080;">or</span> <span style="color: #7060A8;">remainder</span><span style="color: #0000FF;">(</span><span style="color: #000000;">count</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1e5</span><span style="color: #0000FF;">)=</span><span style="color: #000000;">0</span> <span style="color: #008080;">then</span>
elsif count=26828 or remainder(count,1e5)=0 then
<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;">"The %,7d%s Blum integer is: %,9d\n"</span><span style="color: #0000FF;">,</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">count</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">ord</span><span style="color: #0000FF;">(</span><span style="color: #000000;">count</span><span style="color: #0000FF;">),</span><span style="color: #000000;">n</span><span style="color: #0000FF;">})</span>
printf(1,"The %,7d%s Blum integer is: %,9d\n", {count,ord(count),n})
<span style="color: #008080;">if</span> <span style="color: #000000;">count</span><span style="color: #0000FF;">=</span><span style="color: #000000;">4e5</span> <span style="color: #008080;">then</span> <span style="color: #008080;">exit</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
if count=4e5 then exit end if
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
end if
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
end if
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
end for
<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;">"\nPercentage distribution of the first 400,000 Blum integers:\n"</span><span style="color: #0000FF;">)</span>
printf(1,"\nPercentage distribution of the first 400,000 Blum integers:\n")
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">,</span><span style="color: #000000;">n</span> <span style="color: #008080;">in</span> <span style="color: #000000;">counts</span> <span style="color: #008080;">do</span>
for i,n in counts do
<span style="color: #008080;">if</span> <span style="color: #000000;">n</span> <span style="color: #008080;">then</span>
if n then
<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;">" %6.3f%% end in %d\n"</span><span style="color: #0000FF;">,</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">n</span><span style="color: #0000FF;">/</span><span style="color: #000000;">4000</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">})</span>
printf(1," %6.3f%% end in %d\n", {n/4000, i})
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
end if
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
end for
<!--</syntaxhighlight>-->
</syntaxhighlight>
{{out}}
<pre>
Line 1,137 ⟶ 1,750:
break
</syntaxhighlight>{{out}} Same as Wren example.
 
=={{header|Quackery}}==
 
<code>sqrt</code>, <code>isprime</code>, and <code>eratosthenes</code> are defined at [[Sieve of Eratosthenes#Quackery]].
 
<code>from</code>, <code>index</code>, <code>incr</code>, and <code>end</code> are defined at [[Loops/Increment loop index within loop body#Quackery]].
 
In the line <code>600000 eratosthenes</code>, <code>600000</code> suggests foreknowledge of the value of the 26828th Blum integer, and while I was not the first person to complete this task, so knew that <code>524273</code> would suffice, I reasoned that if I had determined the generally linear relationship between <code>n</code> and <code>Blum(n)</code> from computing the first fifty Blum integers with a slower but unbounded primality test I would have felt confident that <code>600000</code> would suffice. See the graphs at https://oeis.org/A016105/graph for confirmation.
 
Precomputing the primes takes a hot minute, but the overhead is worth it for the overall speed gain.
 
<code>blum</code> returns <code>0</code> (i.e. <code>false</code>) if the number passed to it, and the value of the smaller divisor (non-zero is taken as <code>true</code>) rather than <code>false</code> and <code>true</code> (i.e. <code>1</code>) as the divisor is available without extra calculation. So as well as listing the Blum integers, their factors are shown in the output.
 
 
<syntaxhighlight lang="Quackery"> 600000 eratosthenes
 
[ dup sqrt
tuck dup * = ] is exactsqrt ( n --> n b )
 
[ dup isprime iff
[ drop false ] done
dup 4 mod 1 != iff
[ drop false ] done
dup exactsqrt iff
[ 2drop false ] done
temp put
3 from
[ 4 incr
index temp share > iff
[ drop false end ]
done
index isprime not if done
dup index /mod 0 != iff
drop done
isprime not if done
drop index end ]
temp release ] is blum ( n --> n )
 
[ dup blum
over echo
say " = "
dup echo
say " * "
/ echo cr ] is echoblum ( n --> )
 
say "The First 50 Blum integers:"
cr cr
[] 1 from
[ 4 incr
index blum if
[ index join ]
dup size 50 = if end ]
witheach echoblum
cr
say "The 26828th Blum integer:"
cr cr
0 1 from
[ 4 incr
index blum if 1+
dup 26828 = if
[ drop index end ] ]
echoblum</syntaxhighlight>
 
{{out}}
 
<pre style="height:40ex">The First 50 Blum integers:
 
21 = 3 * 7
33 = 3 * 11
57 = 3 * 19
69 = 3 * 23
77 = 7 * 11
93 = 3 * 31
129 = 3 * 43
133 = 7 * 19
141 = 3 * 47
161 = 7 * 23
177 = 3 * 59
201 = 3 * 67
209 = 11 * 19
213 = 3 * 71
217 = 7 * 31
237 = 3 * 79
249 = 3 * 83
253 = 11 * 23
301 = 7 * 43
309 = 3 * 103
321 = 3 * 107
329 = 7 * 47
341 = 11 * 31
381 = 3 * 127
393 = 3 * 131
413 = 7 * 59
417 = 3 * 139
437 = 19 * 23
453 = 3 * 151
469 = 7 * 67
473 = 11 * 43
489 = 3 * 163
497 = 7 * 71
501 = 3 * 167
517 = 11 * 47
537 = 3 * 179
553 = 7 * 79
573 = 3 * 191
581 = 7 * 83
589 = 19 * 31
597 = 3 * 199
633 = 3 * 211
649 = 11 * 59
669 = 3 * 223
681 = 3 * 227
713 = 23 * 31
717 = 3 * 239
721 = 7 * 103
737 = 11 * 67
749 = 7 * 107
 
The 26828th Blum integer:
 
524273 = 223 * 2351</pre>
 
=={{header|Raku}}==
Line 1,249 ⟶ 1,983:
 
26828th Blum number: 524273
</pre>
 
=={{header|Scala}}==
{{trans|Java}}
<syntaxhighlight lang="Scala">
import scala.collection.mutable
 
object BlumInteger extends App {
var blums = new Array[Int](50)
var blumCount = 0
val lastDigitCounts = mutable.Map[Int, Int]()
var number = 1
 
while (blumCount < 400_000) {
val prime = leastPrimeFactor(number)
if (prime % 4 == 3) {
val quotient = number / prime
if (quotient != prime && isPrimeType3(quotient)) {
if (blumCount < 50) {
blums(blumCount) = number
}
lastDigitCounts(number % 10) = lastDigitCounts.getOrElse(number % 10, 0) + 1
blumCount += 1
if (blumCount == 50) {
println("The first 50 Blum integers:")
blums.grouped(10).foreach(group => println(group.map(i => f"$i%3d").mkString(" ")))
println("")
} else if (blumCount == 26828 || blumCount % 100_000 == 0) {
println(f"The ${blumCount}th Blum integer is: $number%7d")
if (blumCount == 400_000) {
println("\nPercent distribution of the first 400000 Blum integers:")
lastDigitCounts.foreach { case (key, count) =>
println(f" ${count.toDouble / 4000}%6.3f%% end in $key")
}
}
}
}
}
number += (if (number % 5 == 3) 4 else 2)
}
 
def isPrimeType3(aNumber: Int): Boolean = {
if (aNumber < 2) return false
if (aNumber % 2 == 0) return aNumber == 2
if (aNumber % 3 == 0) return aNumber == 3
 
var divisor = 5
while (divisor * divisor <= aNumber) {
if (aNumber % divisor == 0) return false
divisor += 2
}
aNumber % 4 == 3
}
 
def leastPrimeFactor(aNumber: Int): Int = {
if (aNumber == 1) return 1
if (aNumber % 2 == 0) return 2
if (aNumber % 3 == 0) return 3
 
var divisor = 5
while (divisor * divisor <= aNumber) {
if (aNumber % divisor == 0) return divisor
divisor += 2
}
aNumber
}
}
</syntaxhighlight>
{{out}}
<pre>
The first 50 Blum integers:
21 33 57 69 77 93 129 133 141 161
177 201 209 213 217 237 249 253 301 309
321 329 341 381 393 413 417 437 453 469
473 489 497 501 517 537 553 573 581 589
597 633 649 669 681 713 717 721 737 749
 
The 26828th Blum integer is: 524273
The 100000th Blum integer is: 2075217
The 200000th Blum integer is: 4275533
The 300000th Blum integer is: 6521629
The 400000th Blum integer is: 8802377
 
Percent distribution of the first 400000 Blum integers:
25.001% end in 1
25.017% end in 3
24.997% end in 7
24.985% end in 9
 
</pre>
 
 
=={{header|Sidef}}==
Takes about 30 seconds:
<syntaxhighlight lang="ruby">func blum_integers(upto) {
 
var L = []
var P = idiv(upto, 3).primes.grep{ .is_congruent(3, 4) }
 
for i in (1..P.end) {
var p = P[i]
for j in (^i) {
var t = p*P[j]
break if (t > upto)
L << t
}
}
 
L.sort
}
 
func blum_first(n) {
var upto = int(4.5*n*log(n) / log(log(n)))
loop {
var B = blum_integers(upto)
if (B.len >= n) {
return B.first(n)
}
upto *= 2
}
}
 
with (50) {|n|
say "The first #{n} Blum integers:"
blum_first(n).slices(10).each { .map{ "%4s" % _ }.join.say }
}
 
say ''
 
for n in (26828, 1e5, 2e5, 3e5, 4e5) {
var B = blum_first(n)
say "#{n.commify}th Blum integer: #{B.last}"
 
if (n == 4e5) {
say ''
for k in (1,3,7,9) {
var T = B.grep { .is_congruent(k, 10) }
say "#{k}: #{'%6s' % T.len} (#{T.len / B.len * 100}%)"
}
}
}</syntaxhighlight>
{{out}}
<pre>
The first 50 Blum integers:
21 33 57 69 77 93 129 133 141 161
177 201 209 213 217 237 249 253 301 309
321 329 341 381 393 413 417 437 453 469
473 489 497 501 517 537 553 573 581 589
597 633 649 669 681 713 717 721 737 749
 
26,828th Blum integer: 524273
100,000th Blum integer: 2075217
200,000th Blum integer: 4275533
300,000th Blum integer: 6521629
400,000th Blum integer: 8802377
 
1: 100005 (25.00125%)
3: 100067 (25.01675%)
7: 99989 (24.99725%)
9: 99939 (24.98475%)
</pre>
 
Line 1,254 ⟶ 2,148:
{{libheader|Wren-math}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./math" for Int
import "./fmt" for Fmt
 
7,794

edits