2,22,222,......
Solution using C language:
#include <stdio.h>
#include <math.h>
int main() {
int n ;
printf("Enter the range\n");
scanf("%d",&n);
float sum = 2*(pow(10, n) - 1 - (9 * n))/81;
printf("sum is %d", sum);
return 0;
}
Output:
Enter the range
3
sum is 879
No comments:
Post a Comment