3 ms·
Probably more about the difference between "echo" and "std::cout << ... << std::endl;" than the recursive function call.
by fabriceleal 8y ago
Probably more about the difference between "echo" and "std::cout << ... << std::endl;" than the recursive function call.
- Sean1708 8y agoI would be very very surprised if printing "2971215073" accounted for more than 1 second of runtime.
- lucozade 8y agoMost of it won't be because the C++ constexpr version has the same IO call and runs in <0.1s.
- syockit 8y agoI think that's because even the std::cout call could be precalculated, so no runtime string concatenation and stream magic is involved.
- VeXocide 8y agostd::endl flushes which isn't cheap, you're generally better off simply steaming in a newline.