Getting WA even if all test cases seem to be right .Help
Your prime function is wrong. Try
1 1 2
Also please use proper indentation. It helps keep the code understandable and easy to debug.
using namespace std;
int prime(int n)
what needs to be improved because error persists
As @everule1 pointed out your prime function is wrong and obviously the error would persist because your prime function is still wrong man.
Try again to find what is the error in your prime function.
Let me give you a hint, why are you iterating till n /2.