Vladislav_Bezruk

Some task

Oct 14th, 2020 (edited)
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. unsigned long long int i,n,a,s;
  5. float s1;
  6.  
  7. int main() {
  8.  
  9.   scanf("%lli %lli\n",&n,&a);
  10.    
  11.   if (a != 1) {
  12.  
  13.   for (i=1;i<=n;i++) {
  14.    
  15.   s = s + i*pow(a,i);  
  16.    
  17.   }
  18.   printf("%lli\n",s);
  19.  
  20.   }
  21.   else
  22.   {
  23.   s1 = n*(n+1)/2;
  24.   s = s1;  
  25.   printf("%lli\n",s);  
  26.   }
  27.  
  28.   return 0;
  29. }
Add Comment
Please, Sign In to add comment