FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java/src/test/java/com/others/FastPowerTest.java at Development · iDev-git/Java · GitHub
iDev-git
Java
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java
/
src
/
test
/
java
/
com
/
others
/
FastPowerTest.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
31 lines (23 loc) · 1.01 KB
Breadcrumbs
Java
/
src
/
test
/
java
/
com
/
others
/
FastPowerTest.java
Copy path
File metadata and controls
31 lines (23 loc) · 1.01 KB
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
27
28
29
30
31
package
com
.
others
;
import
org
.
junit
.
jupiter
.
api
.
Assertions
;
import
org
.
junit
.
jupiter
.
api
.
Test
;
import
java
.
math
.
BigInteger
;
class
FastPowerTest
{
private
void
testLong
(
long
n
,
long
k
,
long
m
) {
long
result
=
FastPower
.
calculate
(
n
,
k
,
m
);
Assertions
.
assertEquals
(
result
,
BigInteger
.
valueOf
(
n
).
modPow
(
BigInteger
.
valueOf
(
k
),
BigInteger
.
valueOf
(
m
)).
longValue
());
}
private
void
testBigInteger
(
BigInteger
n
,
BigInteger
k
,
BigInteger
m
) {
BigInteger
result
=
FastPower
.
calculate
(
n
,
k
,
m
);
Assertions
.
assertEquals
(
result
,
n
.
modPow
(
k
,
m
));
}
@
Test
void
test
() {
testLong
(
2
,
2
,
10
);
testLong
(
100
,
1000
,
20
);
testLong
(
123456
,
123456789
,
234
);
testBigInteger
(
BigInteger
.
TEN
,
BigInteger
.
TEN
,
BigInteger
.
valueOf
(
4
));
testBigInteger
(
new
BigInteger
(
"123456"
),
new
BigInteger
(
"123456789"
),
new
BigInteger
(
"234"
));
testBigInteger
(
new
BigInteger
(
"123456789101112"
),
new
BigInteger
(
"12345678910111213"
),
new
BigInteger
(
"567890"
));
}
}
Back
|
FazBrowse Home
|
New Git URL