It is necessary to find the Euler function from the incoming value, my program does not fit into 2 seconds, how to speed up?
#include <iostream> #include <cmath> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); long long n,res=1,k=0; cin >> n; for (int i=2;i*i<n+1;i++){ while (n%i == 0){ k++; n/=i; } if(k) res*=pow(i,k-1)*(i-1); } if(n-1) res*=(n-1); cout << res; return 0; } 