# may be of number theory...

• Apr 4th 2013, 10:37 AM
kkkxyz
may be of number theory...
A set S contains elements{2^1,2^2,2^3,....,2^9,2^10}.A number 'm' is obtained by adding all possible positive differences of elements of set S.What is the sum of the digits of S ?
• Apr 4th 2013, 07:57 PM
johng
Re: may be of number theory...
Hi,
I assume you want the sum of the (decimal) digits of m. The problem is small enough that I suppose you could do all the computations by hand, but a quick little C program does all the work for you (exact same idea in any language):

Code:

```#include <stdio.h> int powers[10]; int differences[45]; int main(void) {         int i,j,k,m,sumOfDigits;         powers[0] = 2;         for (i=1;i<10;i++) {                 powers[i]=2*powers[i-1];         }         k=0;         for (i=0;i<10;i++) {                 for (j=i+1;j<10;j++) {                         differences[k++]=powers[j]-powers[i];                 }         }         m=0;         for (i=0;i<45;i++) {                 m+=differences[i];         }         printf("The number m is %d\n",m);         sumOfDigits=0;         while (m!=0) {                 sumOfDigits+=m%10;                 m/=10;         }         printf("The sum of the digits of m is %d\n",sumOfDigits);         return(0); }```
The output of the program is m = 14362 and the sum of the digits is 16. I don't see any clever way to find these answers except by brute force computation.