Magic squares/Raku: Difference between revisions
→{{header|Perl 6}}: Add a few comments
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: Style tweaks) |
Thundergnat (talk | contribs) (→{{header|Perl 6}}: Add a few comments) |
||
Line 21:
multi sub gen-sq (2) { # invalid
note "Sorry, can not generate a 2 x 2 magic square." and exit;
}
multi sub gen-sq ($n where {$n % 2}) { # odd
my $x = $n/2;
my $y = 0;
Line 31:
}
multi sub gen-sq ($n where {$n %% 4}) { # doubly even
my $x = 0;
my $y = 0;
Line 46:
}
multi sub gen-sq ($n where {$n %% 2 and $n % 4}) { # singly even
my $h = $n div 2;
gen-sq($h);
|