Advertisement
Grugaloragran

Untitled

Oct 7th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 KB | None | 0 0
  1. #include <stdio.h>
  2. unsigned int sum (int k)
  3. {
  4.     int i;
  5.     unsigned int xn1, xn2, xn3, s, o;
  6.     xn1 = 2;
  7.     xn2 = 9;
  8.         s = 9;
  9.         o = 1;
  10.     for (i=2; i<=k;i++)
  11.     {
  12.         o *= 4;
  13.         xn3 = 5 * xn2 - 6 * xn1 + o;
  14.         s += xn3;
  15.         xn1 = xn2;
  16.         xn2 = xn3;
  17.     }
  18.     return(s);
  19. }
  20. int main(void)
  21. {
  22.     int n;
  23.     unsigned int res;
  24.     scanf_s("%d", &n);
  25.     res = sum(n);
  26.     printf("%d", res);
  27.     return(0);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement