Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
32
Task/Proper-divisors/C-sharp/proper-divisors.cs
Normal file
32
Task/Proper-divisors/C-sharp/proper-divisors.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue