The   proper divisors   of a positive integer N are those numbers, other than N itself, that divide N without remainder.

For N > 1 they will always include 1,   but for N == 1 there are no proper divisors.



Examples

The proper divisors of     6     are   1, 2, and 3.

The proper divisors of   100   are   1, 2, 4, 5, 10, 20, 25, and 50.



Task

 Create a routine to generate all the proper divisors of a number.
 use it to show the proper divisors of the numbers 1 to 10 inclusive.
 Find a number in the range 1 to 20,000 with the most proper divisors. Show the number and just the count of how many proper divisors it has.


Show all output here.



Related tasks

   Amicable pairs
   Abundant, deficient and perfect number classifications
   Aliquot sequence classifications
   Factors of an integer
   Prime decomposition


 
class
	APPLICATION
 
create
	make
 
feature
 
	make
			-- Test the feature proper_divisors.
		local
			list: LINKED_LIST [INTEGER]
			count, number: INTEGER
		do
			across
				1 |..| 10 as c
			loop
				list := proper_divisors (c.item)
				io.put_string (c.item.out + ": ")
				across
					list as l
				loop
					io.put_string (l.item.out + " ")
				end
				io.new_line
			end
			across
				1 |..| 20000 as c
			loop
				list := proper_divisors (c.item)
				if list.count > count then
					count := list.count
					number := c.item
				end
			end
			io.put_string (number.out + " has with " + count.out + " divisors the highest number of proper divisors.")
		end
 
	proper_divisors (n: INTEGER): LINKED_LIST [INTEGER]
			-- Proper divisors of 'n'.
		do
			create Result.make
			across
				1 |..| (n - 1) as c
			loop
				if n \\ c.item = 0 then
					Result.extend (c.item)
				end
			end
		end
 
end
 