Sobes.tech
Junior — Senior

Determining computation time: compilation vs execution

livecode

Task condition

It is necessary to find out which parts of the given code will be computed at compile time and which during runtime.

constexpr int constFact(unsigned value) {
    if (value == 0) {
        return 1;
    }
    return constFact(value - 1) * value;
}

std::cout << constFact(5) << std::endl;

constexpr int result = constFact(5);
std::cout << result << std::endl;