forked from Tecmax/JavaAndroidPractise
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp048.java
More file actions
27 lines (20 loc) · 652 Bytes
/
p048.java
File metadata and controls
27 lines (20 loc) · 652 Bytes
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
/*
* Solution to Project Euler problem 48
* Copyright (c) Project Nayuki. All rights reserved.
*
* https://www.nayuki.io/page/project-euler-solutions
* https://github.com/nayuki/Project-Euler-solutions
*/
import java.math.BigInteger;
public final class p048 implements EulerSolution {
public static void main(String[] args) {
System.out.println(new p048().run());
}
public String run() {
BigInteger modulus = BigInteger.TEN.pow(10);
BigInteger sum = BigInteger.ZERO;
for (int i = 1; i <= 1000; i++)
sum = sum.add(BigInteger.valueOf(i).modPow(BigInteger.valueOf(i), modulus));
return sum.mod(modulus).toString();
}
}