fork download
  1. #include <stdio.h>
  2.  
  3. const int NUMBER = 56287;
  4. const int DIGIT_TO_FIND = 4;
  5. int thisDigit;
  6.  
  7. int findIfDigitIsPresent(int thisNumber) {
  8.  
  9. while (thisNumber != 0) {
  10. thisDigit = thisNumber % 10;
  11. thisNumber = thisNumber / 10;
  12.  
  13. if (thisDigit == DIGIT_TO_FIND) {
  14. return 1;
  15. }
  16. }
  17. return 0;
  18. }
  19.  
  20.  
  21. int main(void) {
  22. int increment = 0;
  23. for(int i = 1; i <= NUMBER; i++) {
  24. if(findIfDigitIsPresent(i)) {
  25. increment = increment + 1;
  26. }
  27. }
  28. printf("%d\n", NUMBER - increment);
  29. return 0;
  30. }
  31.  
  32.  
Success #stdin #stdout 0s 9432KB
stdin
Standard input is empty
stdout
30120