FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ProjectEuler-Java/Util.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
/
Util.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
43 lines (37 loc) · 1.05 KB
Breadcrumbs
ProjectEuler-Java
/
Util.java
Copy path
File metadata and controls
43 lines (37 loc) · 1.05 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
32
33
34
35
36
37
38
39
40
41
42
43
public
class
Util
{
public
static
boolean
isPrime
(
long
p
) {
long
sqrt
= (
long
)
Math
.
sqrt
(
p
) +
1
;
for
(
long
i
=
2
;
i
<
sqrt
;
i
++) {
if
(
p
%
i
==
0
)
return
false
;
}
return
true
;
}
public
static
int
countLetters
(
String
words
) {
int
sum
=
0
;
for
(
int
i
=
0
;
i
<
words
.
length
();
i
++) {
if
(
Character
.
isLetter
(
words
.
charAt
(
i
))) {
sum
++;
}
}
return
sum
;
}
public
static
boolean
isPalindrome
(
int
n
) {
return
isPalindrome
(
String
.
valueOf
(
n
));
}
public
static
boolean
isPalindrome
(
String
str
) {
for
(
int
i
=
0
;
i
<
str
.
length
() /
2
;
i
++) {
if
(
str
.
charAt
(
i
) !=
str
.
charAt
(
str
.
length
() -
1
-
i
))
return
false
;
}
return
true
;
}
public
static
boolean
isTriplet
(
int
a
,
int
b
,
int
c
) {
if
(
a
<
b
&&
b
<
c
) {
if
(
a
*
a
+
b
*
b
==
c
*
c
) {
return
true
;
}
}
return
false
;
}
}
Back
|
FazBrowse Home
|
New Git URL