Numbers whose count of divisors is prime: Difference between revisions

Numbers whose count of divisors is prime en PureBasic
(Numbers whose count of divisors is prime in various BASIC dialents)
(Numbers whose count of divisors is prime en PureBasic)
Line 284:
isPrime = True
END FUNCTION</lang>
 
==={{header|PureBasic}}===
{{trans|FreeBASIC}}
<lang PureBasic>Procedure isPrime(v.i)
If v <= 1 : ProcedureReturn #False
ElseIf v < 4 : ProcedureReturn #True
ElseIf v % 2 = 0 : ProcedureReturn #False
ElseIf v < 9 : ProcedureReturn #True
ElseIf v % 3 = 0 : ProcedureReturn #False
Else
Protected r = Round(Sqr(v), #PB_Round_Down)
Protected f = 5
While f <= r
If v % f = 0 Or v % (f + 2) = 0
ProcedureReturn #False
EndIf
f + 6
Wend
EndIf
ProcedureReturn #True
EndProcedure
 
OpenConsole()
fila.i = 0
 
PrintN("Numbers which count of divisors is prime are:")
 
For n.i = 1 To 100000
num.i = 0
For m.i = 1 To n
If Mod(n, m) = 0
num + 1
EndIf
Next
If isPrime(num) And num <> 2
Print(" " + Str(n) + " ")
fila + 1
If Mod(fila, 5) = 0
PrintN("")
EndIf
EndIf
Next
 
PrintN(#CRLF$ + "Found " + Str(fila) + " numbers")
 
Input()
CloseConsole()
End</lang>
 
==={{header|Yabasic}}===
2,123

edits