File tree 2 files changed +33
-2
lines changed
2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change
1
+ // magic number program 1234 is a magic number, if wee add all the number//
2
+ //seperatly 1+2+3+4 =10 again adding the result 1+0= 1 if single digit //
3
+ //number is 1 then given number is magic number else not//
4
+
5
+ import java .io . ;
6
+ class Magic_number
7
+ {
8
+ public static void main (String ar [])
9
+ {
10
+
11
+ BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
12
+ int n ,v ,t ,d =0 ,s ;
13
+ System .out .println ("Enter the number" );
14
+ n =Integer .parseInt (br .readLine ());
15
+ for (v =n ;v >9 ;v =s ){
16
+ for (t =v ,s =0 ;t >0 ;t =t /10 ) {
17
+ d =t %10 ;
18
+ s =s +d ;
19
+ }
20
+ }
21
+ if (v ==1 )
22
+ {
23
+ System .out .println ("The entered number is magic number" );
24
+ }
25
+ else
26
+ {
27
+ System .out .println ("The entered number is NOT magic number" );
28
+
29
+ }
30
+ }
31
+ }
Original file line number Diff line number Diff line change 6
6
*/
7
7
import java .util .Scanner ;
8
8
9
- class Palindrome_or_not
10
- {
9
+ class Palindrome_or_not {
10
+
11
11
public static void main (Sting args [])
12
12
{
13
13
Scanner x = new Scanner (System .in );
You can’t perform that action at this time.
0 commit comments