Merge pull request #57 from ashish4321/master

floyd triangle
This commit is contained in:
Anup Kumar Panwar 2017-06-16 18:20:42 +05:30 committed by GitHub
commit 4c6ea58203
3 changed files with 48 additions and 0 deletions

BIN
.DS_Store vendored

Binary file not shown.

19
ft.java Normal file
View File

@ -0,0 +1,19 @@
import java.util.Scanner;
class FloydTriangle
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number of rows which you want in your Floyd Triangle: ");
int r = sc.nextInt();
int n=0;
for(int i=0; i<r; i++)
{
for(int j=0; j<=i; j++)
{
System.out.print(++n+" ");
}
System.out.println();
}
}
}

29
krishnamurthy.java Normal file
View File

@ -0,0 +1,29 @@
import java.util.Scanner;
class krishnamurthy
{
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");
}
}