We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Divisible Numbers
Divisible Numbers
+ 0 comments Here is Divisible Numbers problem solution in Python Java C++ and C programming - https://programs.programmingoneonone.com/2021/07/hackerrank-divisible-numbers-problem-solution.html
+ 0 comments static int divisibleNumbers(int n) { /* * Write your code here. */ int a; for (int i = n; ; i += n) { int sum = 0, product = 1, q = i, count = 0; boolean flag = true; while (q > 0) { int rem = q % 10; if (rem == 0) { flag = false; break; } sum += rem; product *= rem; count++; q /= 10; } if (flag) { if (sum >= product) { a = count; break; } else continue; } continue; } return a; }
I'm really not getting what to do about this???
+ 0 comments Trying in Python. Not getting a lot of the test cases beacuse of timeouts. Any hint as to what I can do to minimize the time ? you would still need to calculate the sum and product of each iteration ?
+ 1 comment whats the answer
+ 0 comments HI I am trying to solve it through Python3. My logic seems fine, but not able to reach higher iterations. I am using [ for i in range(1,1000000) ] to reach m values. Can by anymeans i improve my code??
Load more conversations
Sort 25 Discussions, By:
Please Login in order to post a comment