Skip to content

Commit 01b486e

Browse files
authored
Create power.java
1 parent 68c9cd1 commit 01b486e

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

power.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
public class JavaExample {
2+
public static void main(String[] args) {
3+
//Here number is the base and p is the exponent
4+
int number = 2, p = 5;
5+
long result = 1;
6+
7+
//Copying the exponent value to the loop counter
8+
int i = p;
9+
for (;i != 0; --i)
10+
{
11+
result *= number;
12+
}
13+
14+
//Displaying the output
15+
System.out.println(number+"^"+p+" = "+result);
16+
}
17+
}

0 commit comments

Comments
 (0)