FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java_Fundamentals/CheckArmstrong.java at main · devdeepak06/Java_Fundamentals · GitHub
devdeepak06
/
Java_Fundamentals
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java_Fundamentals
/
CheckArmstrong.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
39 lines (36 loc) · 833 Bytes
Breadcrumbs
Java_Fundamentals
/
CheckArmstrong.java
Copy path
File metadata and controls
39 lines (36 loc) · 833 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
28
29
30
31
32
33
34
35
36
37
38
39
/*
Check Armstrong
Write a Program to determine if the given number is Armstrong number or not. Print true if number is armstrong, otherwise print false.
An Armstrong number is a number (with digits n) such that the sum of its digits raised to nth power is equal to the number itself.
For example,
371, as 3^3 + 7^3 + 1^3 = 371
1634, as 1^4 + 6^4 + 3^4 + 4^4 = 1634
*/
import
java
.
util
.
Scanner
;
public
class
CheckArmstrong
{
public
static
void
main
(
String
[]
args
) {
Scanner
s
=
new
Scanner
(
System
.
in
);
int
a
,
b
,
c
,
r
,
f
,
sum
=
0
,
i
,
n
=
0
;
c
=
s
.
nextInt
();
a
=
c
;
b
=
c
;
while
(
c
>
0
)
{
c
=
c
/
10
;
n
++;
}
while
(
a
>
0
)
{
f
=
1
;
r
=
a
%
10
;
for
(
i
=
1
;
i
<=
n
;
i
++)
f
=
f
*
r
;
sum
=
sum
+
f
;
a
=
a
/
10
;
}
if
(
b
==
sum
)
System
.
out
.
println
(
"true"
);
else
System
.
out
.
println
(
"false"
);
}
}
Back
|
FazBrowse Home
|
New Git URL