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 x, int n){// x^n int result = 1; 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
test
test1
exp 3
Problem: rstring
Find a dot in a string
Решето Эратосфена
different ways to add parenthesis leetcode #241
bikeride
4.a
sq-buzz