Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. static int findDigits(int n) {
  2. int count=0;
  3. int num=0;
  4. while(n!=0)
  5. {
  6. num=n%10;
  7. if(num!=0 && n%num==0)
  8. count++;
  9. n=n/10;
  10. }
  11. return count;
  12. }
  13.  
  14. CASE:
  15. 11
  16. 123456789
  17. 114108089
  18. 110110015
  19. 121
  20. 33
  21. 44
  22. 55
  23. 66
  24. 77
  25. 88
  26. 106108048
  27.  
  28. CORRECT ANSWERS:
  29. 3
  30. 3
  31. 6
  32. 2
  33. 2
  34. 2
  35. 2
  36. 2
  37. 2
  38. 2
  39. 5
  40.  
  41. MY ANSWERS:
  42. 2
  43. 6
  44. 4
  45. 6
  46. 3
  47. 2
  48. 2
  49. 2
  50. 2
  51. 2
  52. 2
  53. 4
  54.  
  55. if(num!=0 && n%num==0)
  56.  
  57. static int findDigits(int n) {
  58. int count=0;
  59. int num;
  60. int number = n;
  61. while(n > 0)
  62. {
  63. num=n%10;
  64. if(num!=0 && number%num==0)
  65. count++;
  66. n=n/10;
  67. }
  68. return count;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement