py lang:
a = 3 pow(3, a)
C++ lang:
#include <iostream>
#include <math.h>
int main() {
int a = 3;
std::cout << pow(3, a);
}
After I ran it on OUTPUT windows of VS Code, the C++ result exited in approximately 1,3 sec. Meanwhile, python program exited in approximately 0,15 sec. Why does that happen? I’m a new to C++ and I don’t know much about this language. Pls can someone explain for me? Is there a method to accelerate the C++ program?
I have searched it on some websites but no results were found. I can’t use “x*x” in some cases like:
S(n) = 3 + 3^2 + 3^3 + 3^4 +…+ 3^n
Unknown1712 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
7