Factors of an integer: Difference between revisions

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