Anonymous user
Factors of an integer: Difference between revisions
→{{header|D}}: add implementation
(Added R code) |
(→{{header|D}}: add implementation) |
||
Line 14:
(print (factors 45))</lang>
(1 3 5 9 15)
=={{header|D}}==
<lang d>
int[]factors(int num) {
int[]ret;
for(n=1;n<=num;n++) if (num%n==0) ret ~= n;
}
</lang>
=={{header|Java}}==
{{works with|Java|1.5+}}
|