Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5c10b90

Browse files
committed
Updated krishnamurthy.java
1 parent970be08 commit5c10b90

File tree

1 file changed

+25
-27
lines changed

1 file changed

+25
-27
lines changed

‎Others/krishnamurthy.java

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
11
importjava.util.Scanner;
22

3-
classkrishnamurthy
4-
{
5-
intfact(intn)
6-
{
7-
inti,p=1;
8-
for(i=n;i>=1;i--)
9-
p=p*i;
10-
returnp;
11-
}
12-
publicstaticvoidmain(Stringargs[])
13-
{
14-
Scannersc=newScanner(System.in);
15-
inta,b,s=0;
16-
System.out.print("Enter the number : ");
17-
a=sc.nextInt();
18-
intn=a;
19-
while(a>0)
20-
{
21-
b=a%10;
22-
s=s+fact(b);
23-
a=a/10;
24-
}
25-
if(s==n)
26-
System.out.print(n+" is a krishnamurthy number");
27-
else
28-
System.out.print(n+" is not a krishnamurthy number");
29-
}
3+
classkrishnamurthy {
4+
staticintfact(intn) {
5+
inti,p =1;
6+
for (i =n;i >=1;i--)
7+
p =p *i;
8+
returnp;
9+
}
10+
11+
publicstaticvoidmain(Stringargs[]) {
12+
Scannersc =newScanner(System.in);
13+
inta,b,s =0;
14+
System.out.print("Enter the number : ");
15+
a =sc.nextInt();
16+
intn =a;
17+
while (a >0) {
18+
b =a %10;
19+
s =s +fact(b);
20+
a =a /10;
21+
}
22+
if (s ==n)
23+
System.out.print(n +" is a krishnamurthy number");
24+
else
25+
System.out.print(n +" is not a krishnamurthy number");
26+
sc.close();
27+
}
3028
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp