File tree Expand file tree Collapse file tree 3 files changed +48
-0
lines changed Expand file tree Collapse file tree 3 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments