Question: Checking if a number X is a multiple of another number Y is easy when it is small enough to be stored in a

 Checking if a number X is a multiple of another number Y  is easy when it is small enough to be stored in a 
 

Checking if a number X is a multiple of another number Y is easy when it is small enough to be stored in a variable of integer type (e.g., int, long int). We just have to check if the remainder of the division of X by Y is zero (i.e., X%Y=0). However, when the number is too large, this can be a tricky task. Luckily, when dealing with multiples of 11 (Y=11), there is another way of performing this check: if the difference of the sum of the digits at odd places and even places of X is 0 or a multiple of 11, then X is a multiple of 11 as well. Example #1: 3 Example # 2: 2 X=323455693 6 (3+3+5+6+3)-(2+4+5+9)=20-20-0 The difference is 0, thus X is a multiple of 11 X-31416 6 (3+4+6)-(1+1)-13-2-11 The difference is 11, thus X is a multiple of 11 Considering that X can be a very large number (up to 1000 digits), can you write a program that identifies multiples of 11?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Network Questions!