Skip to content

Instantly share code, notes, and snippets.

@thmain
Created August 21, 2017 01:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thmain/e70e9e96264f8c08b80643e8ffe7e732 to your computer and use it in GitHub Desktop.
Save thmain/e70e9e96264f8c08b80643e8ffe7e732 to your computer and use it in GitHub Desktop.
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