/*
* Problem : Given 2 number x and y where 2 <= x <= 10^100 and 2 <= y<= 10^6.
* Algorithm : Long division Method.
* Variables:
* dividend - Each element of dividend aray represent a digit of x. dividend[0] = Most significant Digit
* divisor - y
* size - No. of digits in x
* If x is divisible by y then return true else return false.
*/
#define len 1000000
bool divide(int dividend[], int divisor, int size) {
int rem, d, index;
rem = d = index = 0;
while(true) {
d = rem;
while( d < divisor && index < size ) {
d = d*10 + dividend[index++];
}
rem = d % divisor;
if(index >= size) {
if(rem == 0) {
return true;
}else {
return false;
}
}
}
}
Monday, 7 April 2014
Program to check whether x ( 2 <= x <= 10^100) is divisible by y ( 2 <= y <= 10^6) .
Subscribe to:
Post Comments (Atom)
Get away free Amazon cins with this one. I acquired a fantastic generator. I am applying it everyday.
ReplyDeleteFree Amazon gift card Codes
good work on the coding,thanks for sharing.
ReplyDeleteHNI Tips in Silver
nice blog
ReplyDeleteAmazon Discount Coupons Codes & Offers
Wonderful blog post on aws.
ReplyDeleteAWS Training in Chennai