FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java/Others/Krishnamurthy.java at dev · primary-code-test/Java · GitHub
primary-code-test
Java
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java
/
Others
/
Krishnamurthy.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
27 lines (24 loc) · 597 Bytes
Breadcrumbs
Java
/
Others
/
Krishnamurthy.java
Copy path
File metadata and controls
27 lines (24 loc) · 597 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
27
package
Others
;
import
java
.
util
.
Scanner
;
class
Krishnamurthy
{
static
int
fact
(
int
n
) {
int
i
,
p
=
1
;
for
(
i
=
n
;
i
>=
1
;
i
--)
p
=
p
*
i
;
return
p
;
}
public
static
void
main
(
String
args
[]) {
Scanner
sc
=
new
Scanner
(
System
.
in
);
int
a
,
b
,
s
=
0
;
System
.
out
.
print
(
"Enter the number : "
);
a
=
sc
.
nextInt
();
int
n
=
a
;
while
(
a
>
0
) {
b
=
a
%
10
;
s
=
s
+
fact
(
b
);
a
=
a
/
10
;
}
if
(
s
==
n
)
System
.
out
.
print
(
n
+
" is a krishnamurthy number"
);
else
System
.
out
.
print
(
n
+
" is not a krishnamurthy number"
);
sc
.
close
();
}
}
Back
|
FazBrowse Home
|
New Git URL