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
  • Apply
  • Hiring developers?
  1. Prepare
  2. Algorithms
  3. Dynamic Programming
  4. Divisible Numbers
  5. Discussions

Divisible Numbers

Problem
Submissions
Leaderboard
Discussions
Editorial

    You are viewing a single comment's thread. Return to all comments →

  • 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
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy