diff --git a/README.md b/README.md index 15fbb6ec..e780c7e6 100644 --- a/README.md +++ b/README.md @@ -402,8 +402,8 @@ In order to achieve greater coverage and encourage more people to contribute to - - + + diff --git a/src/scala/Exponentiation.scala b/src/scala/Exponentiation.scala new file mode 100644 index 00000000..0640a121 --- /dev/null +++ b/src/scala/Exponentiation.scala @@ -0,0 +1,9 @@ +def exponentiation(base: Int, exponent: Int): Int = { + (1 to exponent) + .map(_ => base) + .reduce(_ * _) +} + +object Main extends App { + println("5 ^ 3 = " + exponentiation(5, 3)) +}