Created
March 9, 2015 15:27
-
-
Save keck/2c6a04fa22fc9de6a64d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://twitter.com/mjdominus/status/574937856298369024 | |
# What is the biggest five digit number ABCDE that is divisible by BCDE, CDE, DE and E? | |
use strict; | |
for (my $i = 99999; $i>9999; $i--){ | |
map { | |
my $div = join '', (split '', $i)[$_ .. 4]; | |
next if ($div == 0 ) || ( $i % $div ); | |
} 1 .. 4; | |
print "$i\n"; | |
exit; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment