Skip to content

Commit c59462a

Browse files
authored
Create exponenciacao-recursiva.java
Exponenciação recursiva em Java
1 parent 6a1cf64 commit c59462a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/java/exponenciacao-recursiva.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Main {
2+
3+
public static long exponenciacao (long base, long expoente){ //exponenciacao recursiva
4+
if(expoente==0) return 1;
5+
return (base * exponenciacao(base, expoente-1));
6+
}
7+
8+
public static void main(String args[]) {
9+
System.out.println("5 ^ 3 = " + exponenciacao(5,3));
10+
}
11+
}

0 commit comments

Comments
 (0)