Boston Nmber problem with code

I have solved the boston number problem but I cant understand the type of error while I use sqrt function to get factor of a number and input is some prime number like 29 or 11. My code is https://ide.codingblocks.com/s/182710. When I run the code use code::blocks software I get a different type of error like std::bad_alloc

Hey @Arnabiswas in the factor function after the for loop instead of while(n > 2), if(n > 2) would come, other than that everything is fine in your code!

1 Like