Skip to content

Instantly share code, notes, and snippets.

@talobin
Created April 17, 2014 19:43
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 talobin/11007275 to your computer and use it in GitHub Desktop.
Save talobin/11007275 to your computer and use it in GitHub Desktop.
public class HelloWorld{
public static void main(String []args){
//test 2^2
System.out.println("Test power(2,2)");
System.out.println(power(2,2));
//test 5^3
System.out.println("Test power(5,3)");
System.out.println(power(5,3));
}
public static int power(int x,int m){
if (m==1)
return x;
else
return x* power(x,m-1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment