#include<iostream>
#include<math.h>

using namespace std;

long factorial(long N) {
    if (N < 2) return 1;
    for (int i = N - 1; i > 0; --i) {
        N = N * i;
    }
    return N;
}

double sin_taylor(double x, int N) {
    double res =  0;
    for (int k = 0; k < N; ++k) {
        res += pow(-1, k) * pow(x, 1 + 2*k) / (double)factorial(1 + 2*k);
    }
    return res;
}
void find_interval(int N) {
    const double precision = 0.0000001;
    for (double x = 0; x <= 3.14; x += precision) {
        double real = sin(x);
        double taylor = sin_taylor(x, N);
        //cout << "Real: " << real << " Taylor: " << taylor << endl;
        if (abs(real - taylor) > 0.001) {
            cout << "Interval: [0, " << x - precision << "]" << endl;
            return;
        }
    }
    cout << "Interval: [0, 3.14]" << endl;
}

int main() {
    int N;
    cout << "Gib Dein N ein: ";
    cin >> N;
    cout << "Interval für N: " << endl;
    find_interval(N);
    /*find_interval(1);
    find_interval(2);
    find_interval(3);*/
    return 0;
}
