Q5.13 suggested answer

This forum is for discussing our interview question book. If you want the answer to a follow-up question or to dispute the solutions, this is the place to ask.

Q5.13 suggested answer

Postby daverio » Thu May 24, 2018 10:26 am

As you are using C++ for your answers I suggest the most elegant factorial way for constant.

template <int N>
struct Factorial
enum { value = N * Factorial<N - 1>::value };

template <>
struct Factorial<0>
enum { value = 1 };

This will save time as the factorial is computed a compilation :-)
Posts: 1
Joined: Thu May 24, 2018 10:24 am

Return to Quant Job Interview Questions and Answers

Who is online

Users browsing this forum: No registered users and 1 guest