Change project structure to a Maven Java project + Refactor (#2816)

This commit is contained in:
Aitor Fidalgo Sánchez
2021-11-12 07:59:36 +01:00
committed by GitHub
parent 8e533d2617
commit 9fb3364ccc
642 changed files with 26570 additions and 25488 deletions

View File

@ -0,0 +1,23 @@
package com.thealgorithms.maths;
public class PowRecursion {
public static void main(String[] args) {
assert Double.compare(pow(2, 0), Math.pow(2, 0)) == 0;
assert Double.compare(pow(0, 2), Math.pow(0, 2)) == 0;
assert Double.compare(pow(2, 10), Math.pow(2, 10)) == 0;
assert Double.compare(pow(10, 2), Math.pow(10, 2)) == 0;
}
/**
* Returns the value of the first argument raised to the power of the second
* argument
*
* @param a the base.
* @param b the exponent.
* @return the value {@code a}<sup>{@code b}</sup>.
*/
public static long pow(int a, int b) {
return b == 0 ? 1 : a * pow(a, b - 1);
}
}