Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Anti-primes/C-sharp/anti-primes.cs
Normal file
22
Task/Anti-primes/C-sharp/anti-primes.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
public static void Main() =>
|
||||
Console.WriteLine(string.Join(" ", FindAntiPrimes().Take(20)));
|
||||
|
||||
static IEnumerable<int> FindAntiPrimes() {
|
||||
int max = 0;
|
||||
for (int i = 1; ; i++) {
|
||||
int divisors = CountDivisors(i);
|
||||
if (divisors > max) {
|
||||
max = divisors;
|
||||
yield return i;
|
||||
}
|
||||
}
|
||||
|
||||
int CountDivisors(int n) => Enumerable.Range(1, n / 2).Count(i => n % i == 0) + 1;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue