fork download
  1. //280
  2. #include <iostream>
  3. using namespace std;
  4. long double fact(int f){
  5. if(f < 0)
  6. return 0;
  7. if (f == 0)
  8. return 1;
  9. else
  10. return f * fact(f - 1);
  11. }
  12. int main()
  13. {
  14. long double x[31];
  15. long double y[31];
  16. x[1]=1;
  17. x[2]=2;
  18. y[1]=1;
  19. y[2]=2;
  20. for(int i=3; i<=25;i++){
  21. x[i] = (y[i-1] - y[i-2])/i;
  22. y[i]=((x[i-1]*x[i-1])+x[i-2]+y[i-1])/fact(i);
  23.  
  24. }
  25. for(int i=1;i<=25;i++){
  26. cout<<"x"<<i<<" = ";
  27. cout<<x[i]<<endl;
  28.  
  29. }
  30. for(int i=1;i<=25;i++){
  31. cout<<"y"<<i<<" = ";
  32. cout<<y[i]<<endl;
  33.  
  34. }
  35.  
  36.  
  37. return 0;
  38. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
x1 = 1
x2 = 2
x3 = 0.333333
x4 = -0.208333
x5 = -0.206019
x6 = -0.0220494
x7 = -0.000643149
x8 = 2.29546e-05
x9 = 4.47521e-06
x10 = 5.46089e-08
x11 = 1.61835e-10
x12 = -5.17755e-13
x13 = -8.61536e-15
x14 = -8.14142e-18
x15 = -1.733e-21
x16 = 3.70778e-25
x17 = 3.87524e-28
x18 = 2.16174e-32
x19 = 2.56438e-37
x20 = -2.89547e-42
x21 = -1.51699e-46
x22 = -4.03883e-52
x23 = -2.18228e-58
x24 = 1.07335e-64
x25 = 2.3472e-70
y1 = 1
y2 = 2
y3 = 1.16667
y4 = 0.136574
y5 = 0.00427758
y6 = -0.000224461
y7 = -4.08248e-05
y8 = -5.47863e-07
y9 = -1.77386e-09
y10 = 6.32518e-12
y11 = 1.12114e-13
y12 = 1.14006e-16
y13 = 2.59891e-20
y14 = -5.93904e-24
y15 = -6.5883e-27
y16 = -3.89117e-31
y17 = -4.87227e-36
y18 = 5.79126e-41
y19 = 3.1857e-45
y20 = 8.88542e-51
y21 = 5.01925e-57
y22 = -2.57604e-63
y23 = -5.86799e-69
y24 = -6.50953e-76
y25 = -1.40691e-83