Proper divisors: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 4,211: | Line 4,211: | ||
Number in the range 1 to 20,000 with the most proper divisors is : 15120 |
Number in the range 1 to 20,000 with the most proper divisors is : 15120 |
||
15120 count 79 proper divisors</pre> |
15120 count 79 proper divisors</pre> |
||
=={{header|Visual Basic .NET}}== |
|||
{{trans|C#}} |
|||
<lang vbnet>Module Module1 |
|||
Function ProperDivisors(number As Integer) As IEnumerable(Of Integer) |
|||
Return Enumerable.Range(1, number / 2).Where(Function(divisor As Integer) number Mod divisor = 0) |
|||
End Function |
|||
Sub Main() |
|||
For Each number In Enumerable.Range(1, 10) |
|||
Console.WriteLine("{0}: {{{1}}}", number, String.Join(", ", ProperDivisors(number))) |
|||
Next |
|||
Dim record = Enumerable.Range(1, 20000).Select(Function(number) New With {.Number = number, .Count = ProperDivisors(number).Count()}).OrderByDescending(Function(currentRecord) currentRecord.Count).First() |
|||
Console.WriteLine("{0}: {1}", record.Number, record.Count) |
|||
End Sub |
|||
End Module</lang> |
|||
{{out}} |
|||
<pre>1: {} |
|||
2: {1} |
|||
3: {1} |
|||
4: {1, 2} |
|||
5: {1} |
|||
6: {1, 2, 3} |
|||
7: {1} |
|||
8: {1, 2, 4} |
|||
9: {1, 3} |
|||
10: {1, 2, 5} |
|||
15120: 79</pre> |
|||
=={{header|zkl}}== |
=={{header|zkl}}== |