Factors of an integer: Difference between revisions
Added Gambas and XBasic
(Added Gambas and XBasic) |
|||
Line 1,196:
96 => 1 2 3 4 6 8 12 16 24 32 48 96
</pre>
==={{header|Gambas}}===
{{trans|FreeBASIC}}
<syntaxhighlight lang="vbnet">Public Sub Main()
printFactors(11)
printFactors(21)
printFactors(32)
printFactors(45)
printFactors(67)
printFactors(96)
End
Sub printFactors(n As Integer)
If n < 1 Then Return
Print n; " =>";
For i As Integer = 1 To n / 2
If n Mod i = 0 Then Print i; " ";
Next
Print n
End Sub</syntaxhighlight>
==={{header|Chipmunk Basic}}===
Line 1,834 ⟶ 1,858:
<pre>cell formula is "=Factors(840)"
resultant value is "1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 15, 20, 21, 24, 28, 30, 35, 40, 42, 56, 60, 70, 84, 105, 120, 140, 168, 210, 280, 420, 840"</pre>
==={{header|XBasic}}===
{{trans|BASIC256}}
{{works with|Windows XBasic}}
<syntaxhighlight lang="qbasic">PROGRAM "Factors of an integer"
VERSION "0.0000"
DECLARE FUNCTION Entry ()
DECLARE FUNCTION printFactors (n)
FUNCTION Entry ()
printFactors(11)
printFactors(21)
printFactors(32)
printFactors(45)
printFactors(67)
printFactors(96)
END FUNCTION
FUNCTION printFactors (n)
PRINT n; " =>";
FOR i = 1 TO n / 2
IF n MOD i = 0 THEN PRINT i; " ";
NEXT i
PRINT n
END FUNCTION
END PROGRAM</syntaxhighlight>
==={{header|Yabasic}}===
|