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
Find a dot in a string
Symmetric Tree
preincrement
Java # Faktöriyel
상속1
default constructor
hondaa11
HelloWorld2
frequency of char
1st