I am not scored full for the LCM problem.
Can you please tell me what is wrong in my code.
Problem:
https://online.codingblocks.com/app/player/276028/content/265899/10075/code-challenge
My solution:
#######include
using namespace std;
int main(){
int n1, n2;
cin>>n1>>n2;
int div = 1;
int fact = 1;
int ans;
if(n1<=n2){
while(div<=n1){
if(n1%div == 0 && n2%div == 0){
fact = fact*div;
}
div++;
}
}
else{
while(div<=n2){
if(n1%div == 0 && n2%div == 0){
fact = fact*div;
}
div++;
}
}
ans = (n1*n2)/fact;
cout<<ans;
return 0;
}