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.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Algorithms
  3. Dynamic Programming
  4. Divisible Numbers
  5. Discussions

Divisible Numbers

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 25 Discussions, By:

recency

Please Login in order to post a comment

  • thecodingsoluti2
    6 months ago+ 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|
    Permalink
  • prathameshbagek1
    4 years ago+ 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|
    Permalink
  • noam_steiner
    4 years ago+ 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|
    Permalink
  • bhattia
    4 years ago+ 1 comment

    whats the answer

    0|
    Permalink
  • amitbikram011
    5 years ago+ 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??

    1|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy