Created
August 21, 2017 01:07
-
-
Save thmain/e70e9e96264f8c08b80643e8ffe7e732 to your computer and use it in GitHub Desktop.
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
public class KPowerN_Naive { | |
public static double kPowerN(int k, int n){ | |
double result = 1; | |
for (int i = 0; i <n ; i++) { | |
result *= k; | |
} | |
return result; | |
} | |
public static void main(String[] args) { | |
int k = 4; | |
int n = 5; | |
System.out.println(k + " power " + n + " : Result: " + kPowerN(k,n)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment