formatted
public class CountTheDigit { public static int nbDig(int n, int d) { String number = ""; int count=0; for(int i=0; i<n; i++) { number=(i*i)+""; count += number.length() - number.replace(d+"", "").length(); } return count; } }
- public class CountTheDigit {
- public static int nbDig(int n, int d) {
String number ="";int count=0;for(int i=0; i<n; i++) {- String number = "";
- int count=0;
- for(int i=0; i<n; i++) {
- number=(i*i)+"";
- count += number.length() - number.replace(d+"", "").length();
}return count;}- }
- return count;
- }
- }