Advertisement
nontawat1996

Extrapolation

Oct 20th, 2011
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int n,i,j,k;
  6. int num[100];
  7. while(1)
  8. {
  9. scanf("%d",&n);
  10. if(n==0) return 0;
  11. for(i=0; i<n; i++) scanf("%d",&num[i]);
  12. scanf("%d",&k);
  13. for (j=n-1; j>0; j--)
  14. {
  15. for (i=0; i<j; i++)
  16. {
  17. num[i]=num[i+1]-num[i];
  18. }
  19. }
  20. for (i=0; i<k; i++)
  21. {
  22. for (j=1; j<n; j++)
  23. {
  24. num[j]+=num[j-1];
  25. }
  26. }
  27. printf("Term %d of the sequence is %hd\n", n+k, num[n-1]);
  28. }
  29. return 0;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement