SHARE
TWEET

Untitled

a guest Dec 9th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. boolean includeNum(int n, int m)
  2.     {
  3.         while(m > 0)
  4.         {
  5.             if(n%10 == m%10)
  6.             {
  7.                 n = n/10;
  8.                 m= m/10;
  9.             }
  10.             else
  11.                 return false;
  12.         }
  13.         return true;
  14.     }
  15.     int checkNumDigitsSum(int n)
  16.     {
  17.         int sum = 0;
  18.         while(n > 0 )
  19.         {
  20.             sum = sum+ n%10;
  21.             n=n/10;
  22.         }
  23.         return sum;
  24.     }
  25.      int MaxNumber(int n)
  26.      {
  27.          int saveNum = n;
  28.          int counter = 0;
  29.          
  30.          while(saveNum > 0)
  31.             {
  32.                 saveNum= saveNum/10;
  33.                 counter++;
  34.             }
  35.         int checkNumber = n;
  36.        
  37.         while(checkNumber%n != 0 && checkNumDigitsSum(checkNumber)!= n && includeNum(checkNumber,n) == false )
  38.         {
  39.             checkNumber = checkNumber+Math.pow(10,counter);
  40.         }
  41.        
  42.         return checkNumber;
  43.            
  44.      }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top