fork download
  1.  
  2. #include<stdio.h>
  3. double func(double a, double b, int n){
  4. if (n >0){
  5. double x=func( a, b, n-1);
  6. return a*x*(1-x);
  7. }
  8. else{
  9.  
  10. return b;
  11. }
  12.  
  13. }
  14.  
  15. int main(void) {
  16. double a = 3, b =0.01, x;
  17. int n =100;
  18. x = func(a,b,n);
  19. printf("係数a=%lf, 初期値b=%lfのとき,この数列の%d番目の値は%lf \n", a,b,n,x);
  20. return 0;
  21. }
  22.  
  23.  
Success #stdin #stdout 0s 544KB
stdin
Standard input is empty
stdout
係数a=3.000000, 初期値b=0.010000のとき,この数列の100番目の値は0.642931