We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 68c9cd1 commit 01b486eCopy full SHA for 01b486e
1 file changed
power.java
@@ -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