Angel or Devil?

How many positive integers less than 27272 27272 such that the sum of its digits equals to 27 27 ?


The answer is 666.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

You can use this code to get the answer , I will upload an explanation how to solve this using combinatorics soon ,

include <stdio.h>

int main ()

{

int k =1,a,b,c,d,counter=0;

for (k=1;k<=27272;k++)

{ 

    int i=k;

    a=(i % 10);

    i-=a;

    i=i/10;

    b=(i % 10);

    i-=b;

    i=i/10;

    c=(i % 10);

    i-=c;

    i=i/10;

    d=(i % 10);

    i-=d;

    i=i/10;



    if((a+b+c+d+i)==27)

    {

        counter++;

    }

}

printf("counter=%d",counter);

return 0;

}

The output is 666 666

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...