27
loading...
This website collects cookies to deliver better user experience
divisors
assumes that a number has two divisors (1 and itself) and then goes from 2 to half the number to see if there is any other divisors. A special case is made for one, which only has one divisor.solutions
, and set number
to 1. It then increments number
and adds it to the solutions
list if it has eight divisors, continuing until we have 10 numbers.$ ./ch-1.py
24, 30, 40, 42, 54, 56, 66, 70, 78, 88
$ ./ch-1.pl
24, 30, 40, 42, 54, 56, 66, 70, 78, 88
$m
and $n
.$m
which is also divisible by $n
.n
.map { substr( $m, $_, 1 ) } grep { $i & 2**$_ } ( 0 .. $l - 1 )
where $l
is the length of the first number ($m
) and $i
is between 1 and 2$l - 2.$ ./ch-2.py 1234 2
9
$ ./ch-2.py 768 4
3
$ ./ch-2.pl 1234 2
9
$ ./ch-2.pl 768 4
3