-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumberSystem.java
More file actions
75 lines (63 loc) · 1.25 KB
/
NumberSystem.java
File metadata and controls
75 lines (63 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
class Number{
public static void main(String[]args){
int n;
for(n=1;n<=5;n++){
System.out.println(n);
}
}
}
//git num date- 08.01.26
// for reverse of number
class Reverse{
public static void main(String[]args){
int n;
for(n=5;n>=1;n--){
System.out.println(n);
}
}
}
// for even number
class Even{
public static void main(String...args){
int n;
for(n=1;n<=10;n++){
if(n%2==0){
System.out.println(n);
}
}
}
}
//Print odd numbers from 1 to N
// Input: 10 → Output: 1 3 5 7 9
class Odd{
public static void main(String...odd){
int n;
for(n=1;n<=10;n++){
if(n%2!=0){
System.out.println(n);
}
}
}
}
//To count the digit of number
class CountDigitofEachNumber {
public static void main(String[] args) {
int count=0;
for(int num=1234;num>0;num=num/10) {
count++;
}
System.out.println(count);
}
}
//To find the sumof the each digit
class SumofEachDigit {
public static void main(String[] args) {
int num;
int sum=0;
for( num=12345;num>0;num=num/10) {
int rem=num%10;
sum=sum+rem;
}
System.out.println(sum);
}
}