Factors of an integer: Difference between revisions

Content added Content deleted
Line 1,589: Line 1,589:
f = [] of Int32
f = [] of Int32
(1..Math.sqrt(self)).each{ |i|
(1..Math.sqrt(self)).each{ |i|
q, r = self.divmod i
quo, rem = self.divmod i
(f << i; f << q if q != i) if r.zero?
(f << i; f << quo if quo != i) if rem.zero?
}
}
f.sort
f.sort