Skip to content

Commit 9c30576

Browse files
committed
Merge pull request #15 from shlomif/master
Euler: remove trailing space, fix grammar+spelling and add #188 .
2 parents 878d9f1 + 25efd58 commit 9c30576

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

euler/README

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ Project Euler
22
=============
33
http://projecteuler.net/
44

5-
This is a directory to post answers to project euler questions.
5+
This is a directory to post answers to project euler questions.
66

7-
Use the file format prob000-author.pl replaceing 000 with the problem number and author with your name. For example if I am eric256 and I answer problem one I will save it as prob001-eric256.pl
7+
Use the file format prob000-author.pl, while replacing "000" with the problem number and "author" with your name. For example if I am eric256 and I answer problem No. 1, I will save it as prob001-eric256.pl
88

99
Thanks for playing!

euler/prob188-shlomif.pl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use v6;
2+
3+
# Solve Project Euler’s Problem No. 188:
4+
# http://projecteuler.net/problem=188
5+
# “The Hyperexponentiation of a number.”
6+
7+
sub hyperexp_modulo(int $base, int $exp, int $mod) returns int
8+
{
9+
if $exp == 1
10+
{
11+
return ($base % $mod);
12+
}
13+
14+
my Int $mod1 = $base;
15+
my Int $e = 1;
16+
17+
while $mod1 != 1
18+
{
19+
($mod1 *= $base) %= $mod;
20+
$e++;
21+
}
22+
23+
my int $mod_recurse = hyperexp_modulo($base, $exp - 1, $e);
24+
25+
return $base.expmod($mod_recurse, $mod);
26+
}
27+
28+
# print hyperexp_modulo(3, 3, 1000), "\n";
29+
30+
printf "Result == %08d\n", hyperexp_modulo(1777, 1855, 100_000_000);

0 commit comments

Comments
 (0)