fork download
  1. #include <stdio.h>
  2.  
  3. int rec(int n){
  4.  
  5. int a,b,c;
  6. b=1;
  7. c=2;
  8. for(int i=3;i<=n;i++){
  9. a=-2*c+2*b;
  10. b=c;
  11. c=a;
  12. }
  13. return a;
  14. }
  15.  
  16. int main(void){
  17.  
  18. int n=3;
  19. printf("%d",rec(n));
  20. return 0;
  21. }
Success #stdin #stdout 0.01s 5324KB
stdin
Standard input is empty
stdout
-2