Palindromic primes in base 16: Difference between revisions

Palindromic primes in base 16 en FreeBASIC
(added AWK)
(Palindromic primes in base 16 en FreeBASIC)
Line 136:
}
</pre>
 
 
=={{header|FreeBASIC}}==
<lang freebasic>
Function isprime(num As Ulongint) As Boolean
For i As Integer = 2 To Sqr(num)
If (num Mod i = 0) Then Return False
Next i
Return True
End Function
 
Function reverse(Byval text As String) As String
Dim As String text2 = text
Dim As Integer x, lt = Len(text)
For x = 0 To lt Shr 1 - 1
Swap text2[x], text2[lt - x - 1]
Next x
Return text2
End Function
 
Dim As Integer inicio = 2, final = 499, cont = 0
 
For i As Integer = inicio To final
Dim As String hexi = Str(Hex(i))
If isprime(i) = True And hexi = reverse(hexi) Then
cont += 1
Print Hex(i); " ";
End If
Next i
 
Print !"\n\nEncontrados"; cont; " primos palindrómicos entre " & inicio & " y " & final
Sleep
</lang>
{{out}}
<pre>2 3 5 7 B D 11 101 151 161 191 1B1 1C1
 
Encontrados 13 primos palindrómicos entre 2 y 499</pre>
 
 
=={{header|Go}}==
2,136

edits