Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- unsigned long long int i,n,a,s;
- float s1;
- int main() {
- scanf("%lli %lli\n",&n,&a);
- if (a != 1) {
- for (i=1;i<=n;i++) {
- s = s + i*pow(a,i);
- }
- printf("%lli\n",s);
- }
- else
- {
- s1 = n*(n+1)/2;
- s = s1;
- printf("%lli\n",s);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment