WeixiangYan/CodeTransOcean huggingface dataset:
Task: Proper divisors




Go: package main

import (
    "fmt"
    "strconv"
)

func listProperDivisors(limit int) {
    if limit < 1 {
        return
    }
    width := len(strconv.Itoa(limit))
    for i := 1; i <= limit; i++ {
        fmt.Printf("%*d -> ", width, i)
        if i == 1 {
            fmt.Println("(None)")
            continue
        }
        for j := 1; j <= i/2; j++ {
            if i%j == 0 {
                fmt.Printf(" %d", j)
            }
        }
        fmt.Println()
    }
}

func countProperDivisors(n int) int {
    if n < 2 {
        return 0
    }
    count := 0
    for i := 1; i <= n/2; i++ {
        if n%i == 0 {
            count++
        }
    }
    return count
}

func main() {
    fmt.Println("The proper divisors of the following numbers are :\n")
    listProperDivisors(10)
    fmt.Println()
    maxCount := 0
    most := []int{1}
    for n := 2; n <= 20000; n++ {
        count := countProperDivisors(n)
        if count == maxCount {
            most = append(most, n)
        } else if count > maxCount {
            maxCount = count
            most = most[0:1]
            most[0] = n
        }
    }
    fmt.Print("The following number(s) <= 20000 have the most proper divisors, ")
    fmt.Println("namely", maxCount, "\b\n")
    for _, n := range most {
        fmt.Println(n)
    }
}








Ada: generic
   type Result_Type (<>) is limited private;
   None: Result_Type;
   with function One(X: Positive) return Result_Type;
   with function Add(X, Y: Result_Type) return Result_Type 
      is <>;
package Generic_Divisors is
  
  function Process
    (N: Positive; First: Positive := 1) return Result_Type is      
      (if First**2 > N or First = N then None 
      elsif (N mod First)=0 then 
	(if First = 1 or First*First = N 
	   then Add(One(First), Process(N, First+1))
	   else Add(One(First), 
		    Add(One((N/First)), Process(N, First+1))))
      else Process(N, First+1));
      
end Generic_Divisors;
Task: Proper divisors





Java: import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

public class Proper{
    public static List<Integer> properDivs(int n){
        List<Integer> divs = new LinkedList<Integer>();
        if(n == 1) return divs;
        divs.add(1);
        for(int x = 2; x < n; x++){
            if(n % x == 0) divs.add(x);
        }
        
        Collections.sort(divs);
        
        return divs;
    }
    
    public static void main(String[] args){
        for(int x = 1; x <= 10; x++){
            System.out.println(x + ": " + properDivs(x));
        }
        
        int x = 0, count = 0;
        for(int n = 1; n <= 20000; n++){
            if(properDivs(n).size() > count){
                x = n;
                count = properDivs(n).size();
            }
        }
        System.out.println(x + ": " + count);
    }
}







Ada: generic
   type Result_Type (<>) is limited private;
   None: Result_Type;
   with function One(X: Positive) return Result_Type;
   with function Add(X, Y: Result_Type) return Result_Type 
      is <>;
package Generic_Divisors is
  
  function Process
    (N: Positive; First: Positive := 1) return Result_Type is      
      (if First**2 > N or First = N then None 
      elsif (N mod First)=0 then 
	(if First = 1 or First*First = N 
	   then Add(One(First), Process(N, First+1))
	   else Add(One(First), 
		    Add(One((N/First)), Process(N, First+1))))
      else Process(N, First+1));
      
end Generic_Divisors;
Task: Proper divisors







Python: >>> def proper_divs2(n):
...     return {x for x in range(1, (n + 1) // 2 + 1) if n % x == 0 and n != x}
... 
>>> [proper_divs2(n) for n in range(1, 11)]
[set(), {1}, {1}, {1, 2}, {1}, {1, 2, 3}, {1}, {1, 2, 4}, {1, 3}, {1, 2, 5}]
>>> 
>>> n, length = max(((n, len(proper_divs2(n))) for n in range(1, 20001)), key=lambda pd: pd[1])
>>> n
15120
>>> length
79
>>>





Ada: generic
   type Result_Type (<>) is limited private;
   None: Result_Type;
   with function One(X: Positive) return Result_Type;
   with function Add(X, Y: Result_Type) return Result_Type 
      is <>;
package Generic_Divisors is
  
  function Process
    (N: Positive; First: Positive := 1) return Result_Type is      
      (if First**2 > N or First = N then None 
      elsif (N mod First)=0 then 
	(if First = 1 or First*First = N 
	   then Add(One(First), Process(N, First+1))
	   else Add(One(First), 
		    Add(One((N/First)), Process(N, First+1))))
      else Process(N, First+1));
      
end Generic_Divisors;
Task: Proper divisors








VB: dim _proper_divisors(100)

sub proper_divisors(n)
	dim i
	dim _proper_divisors_count = 0
	if n <> 1 then
		for i = 1 to (n \ 2)
			if n %% i = 0 then
				_proper_divisors_count = _proper_divisors_count + 1
				_proper_divisors(_proper_divisors_count) = i 
			end if
		next
	end if
	return _proper_divisors_count
end sub

sub show_proper_divisors(n, tabbed)
	dim cnt = proper_divisors(n)
	print str$(n) + ":"; tab(4);"(" + str$(cnt) + " items) ";
	dim j 
	for j = 1 to cnt
		if tabbed then
			print str$(_proper_divisors(j)),
		else 
			print str$(_proper_divisors(j));
		end if
		if (j < cnt) then print ",";
	next
	print
end sub

dim i
for i = 1 to 10
    show_proper_divisors(i, false)
next

dim c 
dim maxindex = 0
dim maxlength = 0
for t = 1 to 20000
	c = proper_divisors(t)
	if c > maxlength then
		maxindex = t
		maxlength = c
	end if
next

print "A maximum at ";
show_proper_divisors(maxindex, false)




Ada: generic
   type Result_Type (<>) is limited private;
   None: Result_Type;
   with function One(X: Positive) return Result_Type;
   with function Add(X, Y: Result_Type) return Result_Type 
      is <>;
package Generic_Divisors is
  
  function Process
    (N: Positive; First: Positive := 1) return Result_Type is      
      (if First**2 > N or First = N then None 
      elsif (N mod First)=0 then 
	(if First = 1 or First*First = N 
	   then Add(One(First), Process(N, First+1))
	   else Add(One(First), 
		    Add(One((N/First)), Process(N, First+1))))
      else Process(N, First+1));
      
end Generic_Divisors;
Task: Proper divisors

C: #include <stdio.h>
#include <stdbool.h>

int proper_divisors(const int n, bool print_flag)
{
    int count = 0;

    for (int i = 1; i < n; ++i) {
        if (n % i == 0) {
            count++;
            if (print_flag)
                printf("%d ", i);
        }
    }

    if (print_flag)
        printf("\n");

    return count;
}

int main(void)
{
    for (int i = 1; i <= 10; ++i) {
        printf("%d: ", i);
        proper_divisors(i, true);
    }

    int max = 0;
    int max_i = 1;

    for (int i = 1; i <= 20000; ++i) {
        int v = proper_divisors(i, false);
        if (v >= max) {
            max = v;
            max_i = i;
        }
    }

    printf("%d with %d divisors\n", max_i, max);
    return 0;
}
Task: Proper divisors



C#: namespace RosettaCode.ProperDivisors
{
    using System;
    using System.Collections.Generic;
    using System.Linq;

    internal static class Program
    {
        private static IEnumerable<int> ProperDivisors(int number)
        {
            return
                Enumerable.Range(1, number / 2)
                    .Where(divisor => number % divisor == 0);
        }

        private static void Main()
        {
            foreach (var number in Enumerable.Range(1, 10))
            {
                Console.WriteLine("{0}: {{{1}}}", number,
                    string.Join(", ", ProperDivisors(number)));
            }

            var record = Enumerable.Range(1, 20000).Select(number => new
            {
                Number = number,
                Count = ProperDivisors(number).Count()
            }).OrderByDescending(currentRecord => currentRecord.Count).First();
            Console.WriteLine("{0}: {1}", record.Number, record.Count);
        }
    }
}
Task: Proper divisors


C++: #include <vector>
#include <iostream>
#include <algorithm>

std::vector<int> properDivisors ( int number ) {
   std::vector<int> divisors ;
   for ( int i = 1 ; i < number / 2 + 1 ; i++ )
      if ( number % i == 0 )
	 divisors.push_back( i ) ;
   return divisors ;
}

int main( ) {
   std::vector<int> divisors ;
   unsigned int maxdivisors = 0 ;
   int corresponding_number = 0 ;
   for ( int i = 1 ; i < 11 ; i++ ) {
      divisors =  properDivisors ( i ) ;
      std::cout << "Proper divisors of " << i << ":\n" ;
      for ( int number : divisors ) { 
	 std::cout << number << " " ;
      }
      std::cout << std::endl ;
      divisors.clear( ) ;
   }
   for ( int i = 11 ; i < 20001 ; i++ ) {
      divisors =  properDivisors ( i ) ;
      if ( divisors.size( ) > maxdivisors ) {
	 maxdivisors = divisors.size( ) ;
	 corresponding_number = i ;
      }
      divisors.clear( ) ;
   }

   std::cout << "Most divisors has " << corresponding_number <<
      " , it has " << maxdivisors << " divisors!\n" ; 
   return 0 ;
}
Task: Proper divisors





Java: import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

public class Proper{
    public static List<Integer> properDivs(int n){
        List<Integer> divs = new LinkedList<Integer>();
        if(n == 1) return divs;
        divs.add(1);
        for(int x = 2; x < n; x++){
            if(n % x == 0) divs.add(x);
        }
        
        Collections.sort(divs);
        
        return divs;
    }
    
    public static void main(String[] args){
        for(int x = 1; x <= 10; x++){
            System.out.println(x + ": " + properDivs(x));
        }
        
        int x = 0, count = 0;
        for(int n = 1; n <= 20000; n++){
            if(properDivs(n).size() > count){
                x = n;
                count = properDivs(n).size();
            }
        }
        System.out.println(x + ": " + count);
    }
}
Task: Proper divisors







Python: >>> def proper_divs2(n):
...     return {x for x in range(1, (n + 1) // 2 + 1) if n % x == 0 and n != x}
... 
>>> [proper_divs2(n) for n in range(1, 11)]
[set(), {1}, {1}, {1, 2}, {1}, {1, 2, 3}, {1}, {1, 2, 4}, {1, 3}, {1, 2, 5}]
>>> 
>>> n, length = max(((n, len(proper_divs2(n))) for n in range(1, 20001)), key=lambda pd: pd[1])
>>> n
15120
>>> length
79
>>>
Task: Proper divisors








VB: dim _proper_divisors(100)

sub proper_divisors(n)
	dim i
	dim _proper_divisors_count = 0
	if n <> 1 then
		for i = 1 to (n \ 2)
			if n %% i = 0 then
				_proper_divisors_count = _proper_divisors_count + 1
				_proper_divisors(_proper_divisors_count) = i 
			end if
		next
	end if
	return _proper_divisors_count
end sub

sub show_proper_divisors(n, tabbed)
	dim cnt = proper_divisors(n)
	print str$(n) + ":"; tab(4);"(" + str$(cnt) + " items) ";
	dim j 
	for j = 1 to cnt
		if tabbed then
			print str$(_proper_divisors(j)),
		else 
			print str$(_proper_divisors(j));
		end if
		if (j < cnt) then print ",";
	next
	print
end sub

dim i
for i = 1 to 10
    show_proper_divisors(i, false)
next

dim c 
dim maxindex = 0
dim maxlength = 0
for t = 1 to 20000
	c = proper_divisors(t)
	if c > maxlength then
		maxindex = t
		maxlength = c
	end if
next

print "A maximum at ";
show_proper_divisors(maxindex, false)
Task: Proper divisors




Go: package main

import (
    "fmt"
    "strconv"
)

func listProperDivisors(limit int) {
    if limit < 1 {
        return
    }
    width := len(strconv.Itoa(limit))
    for i := 1; i <= limit; i++ {
        fmt.Printf("%*d -> ", width, i)
        if i == 1 {
            fmt.Println("(None)")
            continue
        }
        for j := 1; j <= i/2; j++ {
            if i%j == 0 {
                fmt.Printf(" %d", j)
            }
        }
        fmt.Println()
    }
}

func countProperDivisors(n int) int {
    if n < 2 {
        return 0
    }
    count := 0
    for i := 1; i <= n/2; i++ {
        if n%i == 0 {
            count++
        }
    }
    return count
}

func main() {
    fmt.Println("The proper divisors of the following numbers are :\n")
    listProperDivisors(10)
    fmt.Println()
    maxCount := 0
    most := []int{1}
    for n := 2; n <= 20000; n++ {
        count := countProperDivisors(n)
        if count == maxCount {
            most = append(most, n)
        } else if count > maxCount {
            maxCount = count
            most = most[0:1]
            most[0] = n
        }
    }
    fmt.Print("The following number(s) <= 20000 have the most proper divisors, ")
    fmt.Println("namely", maxCount, "\b\n")
    for _, n := range most {
        fmt.Println(n)
    }
}
Task: Proper divisors



C#: namespace RosettaCode.ProperDivisors
{
    using System;
    using System.Collections.Generic;
    using System.Linq;

    internal static class Program
    {
        private static IEnumerable<int> ProperDivisors(int number)
        {
            return
                Enumerable.Range(1, number / 2)
                    .Where(divisor => number % divisor == 0);
        }

        private static void Main()
        {
            foreach (var number in Enumerable.Range(1, 10))
            {
                Console.WriteLine("{0}: {{{1}}}", number,
                    string.Join(", ", ProperDivisors(number)));
            }

            var record = Enumerable.Range(1, 20000).Select(number => new
            {
                Number = number,
                Count = ProperDivisors(number).Count()
            }).OrderByDescending(currentRecord => currentRecord.Count).First();
            Console.WriteLine("{0}: {1}", record.Number, record.Count);
        }
    }
}








Fortran:  
      function icntprop(num  )
      icnt=0
      do i=1 , num-1
          if (mod(num , i)  .eq. 0)  then
          icnt = icnt + 1
          if (num .lt. 11) print *,'    ',i
          end if
          end do
      icntprop =  icnt
      end function
 
      limit = 20000
      maxcnt = 0
      print *,'N   divisors'
      do j=1,limit,1
      if (j .lt. 11) print *,j
      icnt = icntprop(j)
 
      if (icnt .gt. maxcnt) then
      maxcnt = icnt
      maxj = j
      end if
 
      end do
 
      print *,' '
      print *,' from 1 to ',limit
      print *,maxj,' has max proper divisors: ',maxcnt
      end
Task: Proper divisors


C++: #include <vector>
#include <iostream>
#include <algorithm>

std::vector<int> properDivisors ( int number ) {
   std::vector<int> divisors ;
   for ( int i = 1 ; i < number / 2 + 1 ; i++ )
      if ( number % i == 0 )
	 divisors.push_back( i ) ;
   return divisors ;
}

int main( ) {
   std::vector<int> divisors ;
   unsigned int maxdivisors = 0 ;
   int corresponding_number = 0 ;
   for ( int i = 1 ; i < 11 ; i++ ) {
      divisors =  properDivisors ( i ) ;
      std::cout << "Proper divisors of " << i << ":\n" ;
      for ( int number : divisors ) { 
	 std::cout << number << " " ;
      }
      std::cout << std::endl ;
      divisors.clear( ) ;
   }
   for ( int i = 11 ; i < 20001 ; i++ ) {
      divisors =  properDivisors ( i ) ;
      if ( divisors.size( ) > maxdivisors ) {
	 maxdivisors = divisors.size( ) ;
	 corresponding_number = i ;
      }
      divisors.clear( ) ;
   }

   std::cout << "Most divisors has " << corresponding_number <<
      " , it has " << maxdivisors << " divisors!\n" ; 
   return 0 ;
}









Fortran:  
      function icntprop(num  )
      icnt=0
      do i=1 , num-1
          if (mod(num , i)  .eq. 0)  then
          icnt = icnt + 1
          if (num .lt. 11) print *,'    ',i
          end if
          end do
      icntprop =  icnt
      end function
 
      limit = 20000
      maxcnt = 0
      print *,'N   divisors'
      do j=1,limit,1
      if (j .lt. 11) print *,j
      icnt = icntprop(j)
 
      if (icnt .gt. maxcnt) then
      maxcnt = icnt
      maxj = j
      end if
 
      end do
 
      print *,' '
      print *,' from 1 to ',limit
      print *,maxj,' has max proper divisors: ',maxcnt
      end
Task: Proper divisors

C: #include <stdio.h>
#include <stdbool.h>

int proper_divisors(const int n, bool print_flag)
{
    int count = 0;

    for (int i = 1; i < n; ++i) {
        if (n % i == 0) {
            count++;
            if (print_flag)
                printf("%d ", i);
        }
    }

    if (print_flag)
        printf("\n");

    return count;
}

int main(void)
{
    for (int i = 1; i <= 10; ++i) {
        printf("%d: ", i);
        proper_divisors(i, true);
    }

    int max = 0;
    int max_i = 1;

    for (int i = 1; i <= 20000; ++i) {
        int v = proper_divisors(i, false);
        if (v >= max) {
            max = v;
            max_i = i;
        }
    }

    printf("%d with %d divisors\n", max_i, max);
    return 0;
}










Fortran:  
      function icntprop(num  )
      icnt=0
      do i=1 , num-1
          if (mod(num , i)  .eq. 0)  then
          icnt = icnt + 1
          if (num .lt. 11) print *,'    ',i
          end if
          end do
      icntprop =  icnt
      end function
 
      limit = 20000
      maxcnt = 0
      print *,'N   divisors'
      do j=1,limit,1
      if (j .lt. 11) print *,j
      icnt = icntprop(j)
 
      if (icnt .gt. maxcnt) then
      maxcnt = icnt
      maxj = j
      end if
 
      end do
 
      print *,' '
      print *,' from 1 to ',limit
      print *,maxj,' has max proper divisors: ',maxcnt
      end
Task: Proper divisors





Java: import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

public class Proper{
    public static List<Integer> properDivs(int n){
        List<Integer> divs = new LinkedList<Integer>();
        if(n == 1) return divs;
        divs.add(1);
        for(int x = 2; x < n; x++){
            if(n % x == 0) divs.add(x);
        }
        
        Collections.sort(divs);
        
        return divs;
    }
    
    public static void main(String[] args){
        for(int x = 1; x <= 10; x++){
            System.out.println(x + ": " + properDivs(x));
        }
        
        int x = 0, count = 0;
        for(int n = 1; n <= 20000; n++){
            if(properDivs(n).size() > count){
                x = n;
                count = properDivs(n).size();
            }
        }
        System.out.println(x + ": " + count);
    }
}






Fortran:  
      function icntprop(num  )
      icnt=0
      do i=1 , num-1
          if (mod(num , i)  .eq. 0)  then
          icnt = icnt + 1
          if (num .lt. 11) print *,'    ',i
          end if
          end do
      icntprop =  icnt
      end function
 
      limit = 20000
      maxcnt = 0
      print *,'N   divisors'
      do j=1,limit,1
      if (j .lt. 11) print *,j
      icnt = icntprop(j)
 
      if (icnt .gt. maxcnt) then
      maxcnt = icnt
      maxj = j
      end if
 
      end do
 
      print *,' '
      print *,' from 1 to ',limit
      print *,maxj,' has max proper divisors: ',maxcnt
      end
Task: Proper divisors







Python: >>> def proper_divs2(n):
...     return {x for x in range(1, (n + 1) // 2 + 1) if n % x == 0 and n != x}
... 
>>> [proper_divs2(n) for n in range(1, 11)]
[set(), {1}, {1}, {1, 2}, {1}, {1, 2, 3}, {1}, {1, 2, 4}, {1, 3}, {1, 2, 5}]
>>> 
>>> n, length = max(((n, len(proper_divs2(n))) for n in range(1, 20001)), key=lambda pd: pd[1])
>>> n
15120
>>> length
79
>>>




Fortran:  
      function icntprop(num  )
      icnt=0
      do i=1 , num-1
          if (mod(num , i)  .eq. 0)  then
          icnt = icnt + 1
          if (num .lt. 11) print *,'    ',i
          end if
          end do
      icntprop =  icnt
      end function
 
      limit = 20000
      maxcnt = 0
      print *,'N   divisors'
      do j=1,limit,1
      if (j .lt. 11) print *,j
      icnt = icntprop(j)
 
      if (icnt .gt. maxcnt) then
      maxcnt = icnt
      maxj = j
      end if
 
      end do
 
      print *,' '
      print *,' from 1 to ',limit
      print *,maxj,' has max proper divisors: ',maxcnt
      end
Task: Proper divisors








VB: dim _proper_divisors(100)

sub proper_divisors(n)
	dim i
	dim _proper_divisors_count = 0
	if n <> 1 then
		for i = 1 to (n \ 2)
			if n %% i = 0 then
				_proper_divisors_count = _proper_divisors_count + 1
				_proper_divisors(_proper_divisors_count) = i 
			end if
		next
	end if
	return _proper_divisors_count
end sub

sub show_proper_divisors(n, tabbed)
	dim cnt = proper_divisors(n)
	print str$(n) + ":"; tab(4);"(" + str$(cnt) + " items) ";
	dim j 
	for j = 1 to cnt
		if tabbed then
			print str$(_proper_divisors(j)),
		else 
			print str$(_proper_divisors(j));
		end if
		if (j < cnt) then print ",";
	next
	print
end sub

dim i
for i = 1 to 10
    show_proper_divisors(i, false)
next

dim c 
dim maxindex = 0
dim maxlength = 0
for t = 1 to 20000
	c = proper_divisors(t)
	if c > maxlength then
		maxindex = t
		maxlength = c
	end if
next

print "A maximum at ";
show_proper_divisors(maxindex, false)



Fortran:  
      function icntprop(num  )
      icnt=0
      do i=1 , num-1
          if (mod(num , i)  .eq. 0)  then
          icnt = icnt + 1
          if (num .lt. 11) print *,'    ',i
          end if
          end do
      icntprop =  icnt
      end function
 
      limit = 20000
      maxcnt = 0
      print *,'N   divisors'
      do j=1,limit,1
      if (j .lt. 11) print *,j
      icnt = icntprop(j)
 
      if (icnt .gt. maxcnt) then
      maxcnt = icnt
      maxj = j
      end if
 
      end do
 
      print *,' '
      print *,' from 1 to ',limit
      print *,maxj,' has max proper divisors: ',maxcnt
      end
Task: Proper divisors






PHP: <?php
function ProperDivisors($n) {
  yield 1;
  $large_divisors = [];
  for ($i = 2; $i <= sqrt($n); $i++) {
    if ($n % $i == 0) {
      yield $i;
      if ($i*$i != $n) {
        $large_divisors[] = $n / $i;
      }
    }
  }
  foreach (array_reverse($large_divisors) as $i) {
    yield $i;
  }
}

assert([1, 2, 4, 5, 10, 20, 25, 50] ==
        iterator_to_array(ProperDivisors(100)));

foreach (range(1, 10) as $n) {
  echo "$n =>";
  foreach (ProperDivisors($n) as $divisor) {
    echo " $divisor";
  }
  echo "\n";
}

$divisorsCount = [];
for ($i = 1; $i < 20000; $i++) {
  $divisorsCount[sizeof(iterator_to_array(ProperDivisors($i)))][] = $i;
}
ksort($divisorsCount);

echo "Numbers with most divisors: ", implode(", ", end($divisorsCount)), ".\n";
echo "They have ", key($divisorsCount), " divisors.\n";





Fortran:  
      function icntprop(num  )
      icnt=0
      do i=1 , num-1
          if (mod(num , i)  .eq. 0)  then
          icnt = icnt + 1
          if (num .lt. 11) print *,'    ',i
          end if
          end do
      icntprop =  icnt
      end function
 
      limit = 20000
      maxcnt = 0
      print *,'N   divisors'
      do j=1,limit,1
      if (j .lt. 11) print *,j
      icnt = icntprop(j)
 
      if (icnt .gt. maxcnt) then
      maxcnt = icnt
      maxj = j
      end if
 
      end do
 
      print *,' '
      print *,' from 1 to ',limit
      print *,maxj,' has max proper divisors: ',maxcnt
      end
Task: Proper divisors






PHP: <?php
function ProperDivisors($n) {
  yield 1;
  $large_divisors = [];
  for ($i = 2; $i <= sqrt($n); $i++) {
    if ($n % $i == 0) {
      yield $i;
      if ($i*$i != $n) {
        $large_divisors[] = $n / $i;
      }
    }
  }
  foreach (array_reverse($large_divisors) as $i) {
    yield $i;
  }
}

assert([1, 2, 4, 5, 10, 20, 25, 50] ==
        iterator_to_array(ProperDivisors(100)));

foreach (range(1, 10) as $n) {
  echo "$n =>";
  foreach (ProperDivisors($n) as $divisor) {
    echo " $divisor";
  }
  echo "\n";
}

$divisorsCount = [];
for ($i = 1; $i < 20000; $i++) {
  $divisorsCount[sizeof(iterator_to_array(ProperDivisors($i)))][] = $i;
}
ksort($divisorsCount);

echo "Numbers with most divisors: ", implode(", ", end($divisorsCount)), ".\n";
echo "They have ", key($divisorsCount), " divisors.\n";