Factors of an integer: Difference between revisions

Note this is a Gosu program file e.g., in file IntFactors.gsp. No "main" class necessary.
m (→‎{{header|F Sharp|F#}}: Fixed a few incorrect and unclosed directives)
(Note this is a Gosu program file e.g., in file IntFactors.gsp. No "main" class necessary.)
Line 1,680:
Factors of 999999999999999989: [1 999999999999999989]
Number of factors = 2</pre>
 
=={{header|Gosu}}==
<lang gosu>var numbers = {11, 21, 32, 45, 67, 96}
numbers.each(\ number -> printFactors(number))
 
function printFactors(n: int) {
if (n < 1) return
var result ="${n} => "
(1 .. n/2).each(\ i -> {result += n % i == 0 ? "${i} " : ""})
print("${result}${n}")
}</lang>
 
{{out}}
<pre>
11 => 1 11
21 => 1 3 7 21
32 => 1 2 4 8 16 32
45 => 1 3 5 9 15 45
67 => 1 67
96 => 1 2 3 4 6 8 12 16 24 32 48 96
</pre>
 
=={{Header|Groovy}}==