SHARE
TWEET

Untitled

a guest Dec 9th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Loops {
  2.    
  3.    
  4.     boolean includeNum(int n, int m)
  5.     {
  6.         while(m > 0)
  7.         {
  8.             if(n%10 == m%10)
  9.             {
  10.                 n = n/10;
  11.                 m= m/10;
  12.             }
  13.             else
  14.                 return false;
  15.         }
  16.         return true;
  17.     }
  18.     int checkNumDigitsSum(int n)
  19.     {
  20.         int sum = 0;
  21.         while(n > 0 )
  22.         {
  23.             sum = sum+ n%10;
  24.             n=n/10;
  25.         }
  26.         return sum;
  27.     }
  28.      int MaxNumber(int n)
  29.      {
  30.          int saveNum = n;
  31.          int counter = 0;
  32.          
  33.          while(saveNum > 0)
  34.             {
  35.                 saveNum= saveNum/10;
  36.                 counter++;
  37.             }
  38.         int checkNumber = n;
  39.         int ret = 0;
  40.         boolean t=false;
  41.        
  42.         while(checkNumber%n != 0 && ret!= n && t != true )
  43.         {
  44.             ret=checkNumDigitsSum(checkNumber);
  45.             t = includeNum(checkNumber,n);
  46.             checkNumber = checkNumber+counter*10;
  47.         }
  48.        
  49.         return checkNumber;
  50.      }    
  51.      }
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