Jump to content

Blum integer: Difference between revisions

Added FreeBasic
(Promoted to 'full' task.)
(Added FreeBasic)
Line 218:
Same as Wren example.
</pre>
 
=={{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|Go}}==
2,169

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.