Jordan-Pólya numbers: Difference between revisions

Content added Content deleted
m (→‎{{header|Free Pascal}}: more comments and commatize)
(Added FreeBasic)
Line 218: Line 218:
= (4!)⁸ x (2!)¹⁶
= (4!)⁸ x (2!)¹⁶
</pre>
</pre>

=={{header|FreeBASIC}}==
{{trans|XPL0}}
Simple-minded brute force. No bonus.
<syntaxhighlight lang="vb">Dim Shared As Uinteger Factorials(1+12)

Function isJPNum(m As Uinteger) As Boolean
Dim As Uinteger n = m, limite = 7, i, q
Do
i = limite
Do
q = n / Factorials(i)
If n Mod Factorials(i) = 0 Then
If q = 1 Then Return True
n = q
Else
i -= 1
End If
If i = 1 Then
If limite = 1 Then Return False
limite -= 1
n = m
Exit Do
End If
Loop
Loop
End Function

Dim As Uinteger fact = 1, n
For n = 1 To 12
fact *= n
Factorials(n) = fact
Next

Print "First 50 Jordan-Polya numbers:"
Print " 1";
Dim As Uinteger c, sn
c = 1
n = 2
Do
If isJPNum(n) Then
c += 1
If c <= 50 Then
Print Using "#####"; n;
If c Mod 10 = 0 Then Print
End If
sn = n
End If
n += 2
Loop Until n >= 1e8

Print !"\nThe largest Jordan-Polya number before 100 million: "; sn

Sleep</syntaxhighlight>
{{out}}
<pre>Same as XPL0 entry.</pre>


=={{header|Go}}==
=={{header|Go}}==