Xisepe

g-fun dz

May 2nd, 2022
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.36 KB | None | 0 0
  1. int getIndex(const double x) {
  2.     return ((int)(round(x * 100))) % 100;
  3. }
  4.  
  5. double function(const double *values, const int size, const double x) {
  6.     if (values == NULL || size < 100 || x < 1.0){
  7.         return 0;
  8.     }
  9.     if (x >= 1.0 && x < 2.0) {
  10.         return values[getIndex(x)];
  11.     } else {
  12.         return x * function(values, size, x - 1);
  13.     }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment