Mam taki program:
#include "pch.h"
#include <iostream>
#include <math.h>
unsigned int silnia(unsigned int z) {
return z <= 1 ? 1 : z * silnia(z - 1);
}
double taylor(double x, unsigned int n) {
return n < 1 ? x : (taylor(x, n - 1) + (pow(-1, n)) / silnia(2 * n + 1) * pow(x, (2 * n + 1)));
}
int main() {
unsigned int n;
double x;
std::cout << "podaj x: ";
std::cin >> x;
std::cout << "podaj liczbe wyrazow: ";
std::cin >> n;
std::cout << taylor(x, n);
}
Nie wiem co jest źle bo wyrzuca mi wyniki spoza zakresu sinusa.