FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ProjectEuler-Java/Sol13.java at master · JoshP/ProjectEuler-Java · GitHub
JoshP
ProjectEuler-Java
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
ProjectEuler-Java
/
Sol13.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
23 lines (18 loc) · 667 Bytes
Breadcrumbs
ProjectEuler-Java
/
Sol13.java
Copy path
File metadata and controls
23 lines (18 loc) · 667 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
import
java
.
util
.*;
import
java
.
io
.*;
import
java
.
math
.*;
public
class
Sol13
extends
BaseSolution
{
public
void
runSolution
() {
try
{
Scanner
scanner
=
new
Scanner
(
new
FileInputStream
(
"Sol13.txt"
),
"UTF-8"
);
BigInteger
sum
=
BigInteger
.
ZERO
;
while
(
scanner
.
hasNextLine
()) {
// only the first 11 digits can affect the first 10 digits of the sum
sum
=
sum
.
add
(
new
BigInteger
(
scanner
.
nextLine
().
substring
(
0
,
11
)));
}
System
.
out
.
println
(
sum
.
toString
().
substring
(
0
,
10
));
}
catch
(
Exception
ex
) {
System
.
err
.
println
(
ex
);
}
}
}
Back
|
FazBrowse Home
|
New Git URL