divide two integers!


  • 0
    V
    public class sol
    {
    public static void main(String arg[])
    {
    int a=sc.nextInt();
     int b=sc.nextInt();
     int div=0,carry=0;
     while(a>0)
     {
         if((a-b)>0)
         {
             a=a-b;
             div++;
             
         }
         else
         {
             carry=a;
             a=a-b;
         }
         
     }
     System.out.print(div+" "+carry);
            }
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.