Factors of an integer: Difference between revisions
Content deleted Content added
→{{header|BQN}}: Version based on prime factorization |
→{{header|Sather}}: Use an iterator for factor generation (sadly means factors aren't ordered, but avoids allocation) |
||
Line 5,996:
=={{header|Sather}}==
<lang sather>class MAIN is
factors!(n :INT):
f := #;▼
loop i ::= 2.upto!( n.flt.sqrt.int );
if n%i = 0 then
yield n / i;
end;
end;
end;
Line 6,018 ⟶ 6,016:
loop l ::= a.elt!;
#OUT + "factors of " + l + ": ";
#OUT + ri + " ";
end;
Line 6,025 ⟶ 6,022:
end;
end;
end;
</lang>
=={{header|Scala}}==
|