Numbers whose count of divisors is prime: Difference between revisions

Numbers whose count of divisors is prime in various BASIC dialents
(Numbers whose count of divisors is prime in various BASIC dialents)
Line 163:
Numbers with odd prime divisor counts 2-99999: 79
</pre>
 
 
=={{header|BASIC}}==
==={{header|BASIC256}}===
{{trans|FreeBASIC}}
<lang BASIC256>function isPrime(v)
if v < 2 then return False
if (v mod 2) = 0 then return v = 2
if (v mod 3) = 0 then return v = 3
d = 5
while d * d <= v
if (v mod d) = 0 then return False else d = d + 2
end while
return True
end function
 
row = 0
 
print "Numbers which count of divisors is prime are:"
 
for n = 1 to 1000
num = 0
for m = 1 to n
if (n mod m) = 0 then num = num + 1
next m
if isPrime(num) and num <> 2 then
print ""; n; " ";
row = row + 1
end if
next n
 
print
print "Found "; row; " numbers"
end</lang>
 
==={{header|FreeBASIC}}===
<lang freebasic>Function isPrime(Byval ValorEval As Integer) As Boolean
If ValorEval < 2 Then Return False
If ValorEval Mod 2 = 0 Then Return ValorEval = 2
If ValorEval Mod 3 = 0 Then Return ValorEval = 3
Dim d As Integer = 5
While d * d <= ValorEval
If ValorEval Mod d = 0 Then Return False Else d += 2
Wend
Return True
End Function
 
Dim As Integer row = 0
Dim As Uinteger n, num, m
 
Print "Numbers which count of divisors is prime are:"
 
For n = 1 To 100000
num = 0
For m = 1 To n
If n Mod m = 0 Then num += 1 : End If
Next m
If isPrime(num) And num <> 2 Then
Print Using " ##### "; n;
row += 1
If row Mod 5 = 0 Then Print : End If
End If
Next n
 
Print !"\n\nFound"; row; " numbers"
Sleep</lang>
{{out}}
<pre>Numbers which count of divisors is prime are:
4 9 16 25 49
64 81 121 169 289
361 529 625 729 841
961 1024 1369 1681 1849
2209 2401 2809 3481 3721
4096 4489 5041 5329 6241
6889 7921 9409 10201 10609
11449 11881 12769 14641 15625
16129 17161 18769 19321 22201
22801 24649 26569 27889 28561
29929 32041 32761 36481 37249
38809 39601 44521 49729 51529
52441 54289 57121 58081 59049
63001 65536 66049 69169 72361
73441 76729 78961 80089 83521
85849 94249 96721 97969
 
Found 79 numbers</pre>
 
==={{header|QBasic}}===
{{works with|QBasic}}
{{works with|QuickBasic}}
{{trans|FreeBASIC}}
<lang QBasic>row = 0
 
PRINT "Numbers which count of divisors is prime are:"
 
FOR n = 1 TO 1000
num = 0
FOR m = 1 TO n
IF n MOD m = 0 THEN num = num + 1
NEXT m
IF isPrime(num) AND num <> 2 THEN
PRINT USING " ##### "; n;
row = row + 1
IF row MOD 5 = 0 THEN PRINT
END IF
NEXT n
 
PRINT : PRINT "Found"; row; " numbers"
Sleep
END
 
FUNCTION isPrime (ValorEval)
IF ValorEval < 2 THEN isPrime = False
IF ValorEval MOD 2 = 0 THEN isPrime = 2
IF ValorEval MOD 3 = 0 THEN isPrime = 3
d = 5
WHILE d * d <= ValorEval
IF ValorEval MOD d = 0 THEN isPrime = False ELSE d = d + 2
WEND
isPrime = True
END FUNCTION</lang>
 
==={{header|Yabasic}}===
{{trans|FreeBASIC}}
<lang yabasic>row = 0
 
print "Numbers which count of divisors is prime are:"
 
for n = 1 to 1000
num = 0
for m = 1 to n
if mod(n, m) = 0 then num = num + 1 : fi
next m
if isPrime(num) and num <> 2 then
print n using "#####",
row = row + 1
if mod(row, 5) = 0 then print : fi
end if
next n
 
print "\n\nFound ", row, " numbers"
end
 
sub isPrime(v)
if v < 2 then return False : fi
if mod(v, 2) = 0 then return v = 2 : fi
if mod(v, 3) = 0 then return v = 3 : fi
d = 5
while d * d <= v
if mod(v, d) = 0 then return False else d = d + 2 : fi
end while
return True
end sub</lang>
{{out}}
<pre>
Igual que la entrada de FreeBASIC.
</pre>
 
 
=={{header|C++}}==
2,157

edits