Factors of an integer: Difference between revisions
Content added Content deleted
m (fix bare lang tags) |
|||
Line 428: | Line 428: | ||
return 0; |
return 0; |
||
}</lang>output |
}</lang>output |
||
<pre>3: 1 3 |
|||
120: 1 2 3 4 5 6 8 10 12 15 20 24 30 40 60 120 |
120: 1 2 3 4 5 6 8 10 12 15 20 24 30 40 60 120 |
||
1024: 1 2 4 8 16 32 64 128 256 512 1024 |
1024: 1 2 4 8 16 32 64 128 256 512 1024 |
||
3491888400: 1 2 3 4 5 6 7 8 9 10 11 ...(>1900 numbers)... 1163962800 1745944200 3491888400</ |
3491888400: 1 2 3 4 5 6 7 8 9 10 11 ...(>1900 numbers)... 1163962800 1745944200 3491888400</pre> |
||
=={{header|C++}}== |
=={{header|C++}}== |
||
Line 699: | Line 700: | ||
end program</lang> |
end program</lang> |
||
=={{header|GAP}}== |
=={{header|GAP}}== |
||
<lang># Built-in function |
<lang gap># Built-in function |
||
DivisorsInt(Factorial(5)); |
DivisorsInt(Factorial(5)); |
||
# [ 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 24, 30, 40, 60, 120 ] |
# [ 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 24, 30, 40, 60, 120 ] |
||
Line 1,398: | Line 1,399: | ||
</lang> |
</lang> |
||
Output : |
Output : |
||
< |
<pre> ?- factor(36, L). |
||
L = [1,2,3,4,6,9,12,18,36]. |
L = [1,2,3,4,6,9,12,18,36]. |
||
Line 1,411: | Line 1,412: | ||
?- factor(32767, L). |
?- factor(32767, L). |
||
L = [1,7,31,151,217,1057,4681,32767]. |
L = [1,7,31,151,217,1057,4681,32767].</pre> |
||
</lang> |
|||
=={{header|PureBasic}}== |
=={{header|PureBasic}}== |
||
<lang PureBasic>Procedure PrintFactors(n) |
<lang PureBasic>Procedure PrintFactors(n) |
||
Line 1,501: | Line 1,501: | ||
factors(c(45, 53, 64)) |
factors(c(45, 53, 64)) |
||
</lang> |
</lang> |
||
< |
<pre> |
||
[[1]] |
[[1]] |
||
[1] 1 3 5 9 15 45 |
[1] 1 3 5 9 15 45 |
||
Line 1,508: | Line 1,508: | ||
[[3]] |
[[3]] |
||
[1] 1 2 4 8 16 32 64 |
[1] 1 2 4 8 16 32 64 |
||
</ |
</pre> |
||
=={{header|REALbasic}}== |
=={{header|REALbasic}}== |