-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdigit.java
More file actions
32 lines (28 loc) · 767 Bytes
/
Copy pathdigit.java
File metadata and controls
32 lines (28 loc) · 767 Bytes
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
package codeforces;
public class digit {
static int firstdigit(int n) {
while (n > 10) {
n = n / 10;
}
return n;
}
static int occurance(int n, int d) {
int count = 0;
while (n > 0) {
if (d == n % 10) {
count++;
}
n = n / 10;
}
return count;
}
public static void main(String[] args) {
int n = 633356778;
System.out.println("last digit:" + n % 10);
System.out.println("First digit:" + firstdigit(n));
//which digit repeated how many?
for (int i = 1; i <= 9; i++) {
System.out.println(i + "ase " + occurance(n, i) + "ber");
}
}
}