Ludic numbers: Difference between revisions

Content added Content deleted
(Added FreeBASIC)
(Changed code so that ludic function is only called once for the largest value)
Line 1,202: Line 1,202:
Dim As Integer count = 1, count2
Dim As Integer count = 1, count2
Dim As Integer i, j, k = 1
Dim As Integer i, j, k = 1
Dim As Integer ub = n * 11 '' big enough to deal with up to 2005 ludic numbers
Dim As Integer ub = 22000 '' big enough to deal with up to 2005 ludic numbers
Dim a(2 To ub) As Integer
Dim a(2 To ub) As Integer
For i = 2 To ub : a(i) = i : Next
For i = 2 To ub : a(i) = i : Next
Line 1,239: Line 1,239:
Dim i As Integer
Dim i As Integer
Dim lu() As Integer
Dim lu() As Integer
ludic(25, lu())
ludic(2005, lu())
Print "The first 25 Ludic numbers are :"
Print "The first 25 Ludic numbers are :"
For i = 1 To 25
For i = 1 To 25
Line 1,245: Line 1,245:
Print " ";
Print " ";
Next
Next
Erase lu
Print
Print


Dim As Integer Count = 0
Dim As Integer Count = 0
ludic(1000, lu())
For i = 1 To 1000
For i = 1 To 1000
If lu(i) <= 1000 Then
If lu(i) <= 1000 Then
Line 1,257: Line 1,255:
End If
End If
Next
Next
Erase lu
Print
Print
Print "There are"; count; " Ludic numbers <= 1000"
Print "There are"; count; " Ludic numbers <= 1000"
Line 1,263: Line 1,260:


Print "The 2000th to 2005th Ludics are :"
Print "The 2000th to 2005th Ludics are :"
ludic(2005, lu())
For i = 2000 To 2005
For i = 2000 To 2005
Print lu(i); " ";
Print lu(i); " ";
Next
Next
Erase lu
Print : Print
Print : Print


Line 1,273: Line 1,268:
Dim As Integer j, k, ldc
Dim As Integer j, k, ldc
Dim b As Boolean
Dim b As Boolean
ludic(250, lu())
For i = 1 To 248
For i = 1 To 248
ldc = lu(i)
ldc = lu(i)