Factors of an integer: Difference between revisions
→OB64: (?) move out of the Python section
(→Python: a bit faster by avoiding sets and sorting) |
(→OB64: (?) move out of the Python section) |
||
Line 1,522:
1 2 3 4 6 8 12 16 24 32 48 96
</pre>
==={{header|QB64}}===
<syntaxhighlight lang="qb64">▼
'Task▼
'Compute the factors of a positive integer.▼
'These factors are the positive integers by which the number being factored can be divided to yield a positive integer result.▼
Dim Dividendum As Integer, Index As Integer▼
Randomize Timer▼
Dividendum = Int(Rnd * 1000) + 1▼
Print " Dividendum: "; Dividendum▼
Index = Int(Dividendum / 2)▼
print "Divisors: ";▼
While Index > 0▼
If Dividendum Mod Index = 0 Then Print Index; " ";▼
Index = Index - 1▼
Wend▼
End▼
</syntaxhighlight>▼
==={{header|QBasic}}===
Line 5,615 ⟶ 5,634:
r += [a*b for a in r for b in e]
return r</syntaxhighlight>
▲<syntaxhighlight lang="qb64">
▲'Task
▲'Compute the factors of a positive integer.
▲'These factors are the positive integers by which the number being factored can be divided to yield a positive integer result.
▲Dim Dividendum As Integer, Index As Integer
▲Randomize Timer
▲Dividendum = Int(Rnd * 1000) + 1
▲Print " Dividendum: "; Dividendum
▲Index = Int(Dividendum / 2)
▲print "Divisors: ";
▲While Index > 0
▲ If Dividendum Mod Index = 0 Then Print Index; " ";
▲ Index = Index - 1
▲Wend
▲End
▲</syntaxhighlight>
=={{header|Quackery}}==
|