FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java/Maths/PowRecursion.java at master · java66liu/Java · GitHub
java66liu
/
Java
Public
forked from
TheAlgorithms/Java
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java
/
Maths
/
PowRecursion.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
26 lines (24 loc) · 668 Bytes
Breadcrumbs
Java
/
Maths
/
PowRecursion.java
Copy path
File metadata and controls
26 lines (24 loc) · 668 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package
Maths
;
public
class
PowRecursion
{
public
static
void
main
(
String
[]
args
) {
assert
pow
(
2
,
0
) ==
Math
.
pow
(
2
,
0
);
assert
pow
(
0
,
2
) ==
Math
.
pow
(
0
,
2
);
assert
pow
(
2
,
10
) ==
Math
.
pow
(
2
,
10
);
assert
pow
(
10
,
2
) ==
Math
.
pow
(
10
,
2
);
}
/**
* Returns the value of the first argument raised to the power of the
* second argument
*
* @param a the base.
* @param b the exponent.
* @return the value {@code a}<sup>{@code b}</sup>.
*/
public
static
long
pow
(
int
a
,
int
b
) {
if
(
b
==
0
) {
return
1
;
}
else
{
return
a
*
pow
(
a
,
b
-
1
);
}
}
}
Back
|
FazBrowse Home
|
New Git URL