#include <stdio.h>
unsigned superposition(unsigned m, unsigned n);
int main()
{
printf("1 + 11 + 111 + 1111 + 11111 = %u ", superposition(1, 5));
printf("2 + 22 + 222 + 2222 + 22222 + 222222 = %u ", superposition(2, 6));
printf("3 + 33 + 333 + 3333 + 33333 + 333333 + 3333333 = %u ", superposition(3, 7));
return 0;
}
unsigned superposition(unsigned m, unsigned n)
{
unsigned u = 0, sum = 0;
for (unsigned i = 0; i < n; ++i)
{
u = u * 10 + m;
sum += u;
}
return sum;
}