Skip to content

Commit 4c6ea58

Browse files
Merge pull request TheAlgorithms#57 from ashish4321/master
floyd triangle
2 parents b0c1fcc + b8d98f9 commit 4c6ea58

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

.DS_Store

0 Bytes
Binary file not shown.

ft.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import java.util.Scanner;
2+
class FloydTriangle
3+
{
4+
public static void main(String[] args)
5+
{
6+
Scanner sc = new Scanner(System.in);
7+
System.out.println("Enter the number of rows which you want in your Floyd Triangle: ");
8+
int r = sc.nextInt();
9+
int n=0;
10+
for(int i=0; i<r; i++)
11+
{
12+
for(int j=0; j<=i; j++)
13+
{
14+
System.out.print(++n+" ");
15+
}
16+
System.out.println();
17+
}
18+
}
19+
}

krishnamurthy.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import java.util.Scanner;
2+
class krishnamurthy
3+
{
4+
int fact(int n)
5+
{
6+
int i,p=1;
7+
for(i=n;i>=1;i--)
8+
p=p*i;
9+
return p;
10+
}
11+
public static void main(String args[])
12+
{
13+
Scanner sc=new Scanner(System.in);
14+
int a,b,s=0;
15+
System.out.print("Enter the number : ");
16+
a=sc.nextInt();
17+
int n=a;
18+
while(a>0)
19+
{
20+
b=a%10;
21+
s=s+fact(b);
22+
a=a/10;
23+
}
24+
if(s==n)
25+
System.out.print(n+" is a krishnamurthy number");
26+
else
27+
System.out.print(n+" is not a krishnamurthy number");
28+
}
29+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy