Advertisement
Guest User

Untitled

a guest
Jan 9th, 2019
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. const getGets = (n1) => {
  2. let inde0 = 0;
  3.  
  4. return () => {
  5. const toReturn = n1[inde0];
  6. inde0 ++;
  7. return toReturn;
  8. };
  9. };
  10. // this is the test
  11. const test = [
  12. '42 142',
  13. ];
  14.  
  15. const gets = this.gets || getGets(test);
  16. const print = this.print || console.log;
  17.  
  18. let input = gets().split(' ');
  19.  
  20. let arr = [];
  21.  
  22. let counter = 0;
  23.  
  24. let A = +input[0];
  25. let B = +input[1];
  26.  
  27. for (i = A; i <= B; i++) {
  28. arr.push(i);
  29. }
  30.  
  31. for (i = 0; i < arr.length; i++) {
  32.  
  33. function checkDivisibility(n, digit)
  34. {
  35.  
  36. return (digit != 0 && n % digit == 0);
  37. }
  38.  
  39.  
  40. function allDigitsDivide(n)
  41. {
  42. let temp = n;
  43. while (temp > 0) {
  44.  
  45.  
  46. let digit = n % 10;
  47.  
  48. if ((checkDivisibility(n, digit)) == false)
  49. return false;
  50.  
  51. temp /= 10;
  52. }
  53. return true;
  54. }
  55.  
  56. if (allDigitsDivide(arr[i]) == true ){
  57. counter++;
  58. } else {
  59. continue;
  60. }
  61. }
  62. print(counter);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement