fork download
  1. #include <stdio.h>
  2. int func(int n){
  3. int a[30],i;
  4. a[0]=-1;
  5. for(i=1;i<=n;i++){
  6. a[i]=3*a[i-1]+5;
  7. }
  8. return a[n];
  9. }
  10. int main(void) {
  11. // your code goes here
  12. int n=3;
  13. printf("数列anについて、n=%dの時の値は%d",n,func(n));
  14. return 0;
  15. }
  16.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
数列anについて、n=3の時の値は38