A six digit number is said to be lucky if the sum of its first three digits is equal to the sum of the last three digits. Let S be the sum of all lucky numbers. Find the remainder when S is divided by 13.
I'm assuming that by the word "sum" you mean the "Total number" of lucky numbers. If that is so, then there are: 50,412 such lucky numbers.
50,412 mod 13 = 11
I think they meant "sum" as in actually adding all the lucky numbers together. So if you took every single lucky number that exists, and added them all together, you would get "S".
Is that a coding problem? If so, Guest it would be pleasing if you posted the code you wrote
Do you really think so? It can easily be done as well, since the code I wrote can easily sum them up.
And the sum of 50,412 lucky numbers =27,336,542,310 mod 13 =12
CU: Here is the computer code in question:
a=1;b=0;c=0;d=0;e=0;f=0;p=0; cycle:if(a+b+c==d+e+f, goto loop, goto next); loop:print a*100000+b*10000+c*1000+d*100+e*10+f,", ",;p=p+1; next:f++;if(f<10, goto cycle, 0);f=0;e++;if(e<10, goto cycle, 0);f=0;e=0;d++;if(d<10, goto cycle,0);f=0;e=0;d=0;c++;if(c<10, goto cycle,0);f=0;e=0;d=0;c=0;b++;if(b<10, goto cycle,0);f=0;e=0;d=0;c=0;b=0;a++;if(a<10, goto cycle,0);print"Total = ",p