50 lines
1 KiB
Text
50 lines
1 KiB
Text
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
|