Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
pow x^n
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; import java.lang.*; class Rextester { public static int pow(int xx, int nn){// x^n int result = 1, x=xx, n=nn; for(;n>0;n/=2, x*=x){ if(n%2 == 1){ result *= x; } } return result; } public static void main(String args[]) { int maxN = 10; for(int i=0; i<=maxN; i++){ System.out.println("2^"+i+"=" + pow(2, i)); } } }
run
|
edit
|
history
|
help
0
Homework
MP8 game
JAVA # Cümleye Boşluk Bırakma 2
Quadratic equation
Display Page (Pagination)
2D List Iterator
a+b
4.C
MinMaxArray
Multiples of 3 and 5