Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
22
Task/Proper-divisors/Ceylon/proper-divisors.ceylon
Normal file
22
Task/Proper-divisors/Ceylon/proper-divisors.ceylon
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
shared void run() {
|
||||
|
||||
function divisors(Integer int) =>
|
||||
if(int <= 1)
|
||||
then {}
|
||||
else (1..int / 2).filter((Integer element) => element.divides(int));
|
||||
|
||||
for(i in 1..10) {
|
||||
print("``i`` => ``divisors(i)``");
|
||||
}
|
||||
|
||||
value start = 1;
|
||||
value end = 20k;
|
||||
|
||||
value mostDivisors =
|
||||
map {for(i in start..end) i->divisors(i).size}
|
||||
.inverse()
|
||||
.max(byKey(byIncreasing(Integer.magnitude)));
|
||||
|
||||
print("the number(s) with the most divisors between ``start`` and ``end`` is/are:
|
||||
``mostDivisors?.item else "nothing"`` with ``mostDivisors?.key else "no"`` divisors");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue