Created
November 28, 2022 05:03
-
-
Save xtetsuji/b5ca2578ff55b183da753e31399452eb to your computer and use it in GitHub Desktop.
square-sum-1128.pl
This file contains 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
2^2 + 10^2 + 32^2 = 1128 | |
2^2 + 32^2 + 10^2 = 1128 | |
10^2 + 2^2 + 32^2 = 1128 | |
10^2 + 32^2 + 2^2 = 1128 | |
14^2 + 16^2 + 26^2 = 1128 | |
14^2 + 26^2 + 16^2 = 1128 | |
16^2 + 14^2 + 26^2 = 1128 | |
16^2 + 26^2 + 14^2 = 1128 | |
26^2 + 14^2 + 16^2 = 1128 | |
26^2 + 16^2 + 14^2 = 1128 | |
32^2 + 2^2 + 10^2 = 1128 | |
32^2 + 10^2 + 2^2 = 1128 |
This file contains 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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
my $MAX_NUMBER = 1128; | |
my $BIRTHDAY = 1128; | |
for my $x (1..$MAX_NUMBER) { | |
for my $y (1..$MAX_NUMBER) { | |
for my $z (1..$MAX_NUMBER) { | |
my $sum = $x**2 + $y**2 + $z**2; | |
if ( $sum == $BIRTHDAY ) { | |
print "$x^2 + $y^2 + $z^2 = $BIRTHDAY\n"; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment