Replace "not" with "1" and you have a true statement.
not = 1.
#include<iostream> #include<array> #include<sstream> std::array<int,10> get_frequency (int range_min, int range_max) { if (range_max<range_min) std::swap (range_min, range_max); std::array<int,10> digit {}; for (int count {range_min}; count<=range_max; ++count) { std::stringstream ss {}; ss << count; std::string s {}; ss >> s; for (auto c : s) { ++digit[c-'0']; } } return digit; } int main () { std::array<int,10> digit {}; digit = get_frequency(1, 89); std::cout << "In the range 1 to 89...\n"; for (int d {0}; d<10; ++d) { std::cout << "\tthe digit " << d << " appears " << digit[d] << " times.\n"; } } Output: In the range 1 to 89... the digit 0 appears 8 times. the digit 1 appears 19 times. the digit 2 appears 19 times. the digit 3 appears 19 times. the digit 4 appears 19 times. the digit 5 appears 19 times. the digit 6 appears 19 times. the digit 7 appears 19 times. the digit 8 appears 19 times. the digit 9 appears 9 times.
300 times.
10 times for the one's digit, 1-100 10 times for the ten's digit, 60-70 = 20 times
48
The digit 1 appears 301 times, as opposed to 300 for the digits 2 to 9.
11 times
It appears 20 times.
95
Assuming you mean in the numbers 1, 2, 3, ..., 998, 999, 1000 then the digit 0. (The digit 1 appears 301 times, the digits 2-9 all appear 300 times each, but the digit 0 only appears 192 times.)
146 times.
As a digit in other numbers it appears 20 times
73