#include <cmath>
#include <fstream>
#include <iostream>
#include <string>
using namespace std;

int main() {

    //  Get input from user
    cout << "Enter initial number of nuclei: ";
    double n;
    cin >> n;
    cout << "Enter decay time constant tau: ";
    double tau;
    cin >> tau;
    cout << "Enter time step dt: ";
    double dt;
    cin >> dt;
    cout << "Enter time to end simulation: ";
    double tMax;
    cin >> tMax;
    cout << "Enter name of output file: ";
    string name;
    cin >> name;

    //  Initialize variables and open output file
    double t = 0;
    ofstream file(name.c_str());
    file << t << '\t' << n << '\n';

    //  Calculate results and store in file
    while (t < tMax) {
        n -= n / tau * dt;
        t += dt;
        file << t << '\t' << n << '\n';
    }

    //  Close file
    file.close();
    cout << "Results stored in " << name << endl;

}

