Skip to content

Commit 882963c

Browse files
authored
Create exponenciacao-nao-recursiva.java
Exponenciação não-recursiva
1 parent 6a1cf64 commit 882963c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Main {
2+
3+
public static long exponenciacao(int base, int expoente){
4+
5+
int i;
6+
int result = base;
7+
8+
for(i=0; i<expoente-1; i++)
9+
result *= base;
10+
11+
return result;
12+
}
13+
14+
15+
public static void main(String args[]) {
16+
System.out.println("5 ^ 3 = " + exponenciacao(5,3));
17+
}
18+
}

0 commit comments

Comments
 (0)