[Solved] Why does this program which finds the smallest triangle number with >500 factors crash? [closed]
TL;DR #include <vector> std::vector <unsigned long long int> triangleNumbers(0); int main() { triangleNumbers[0]=10000000000; } You have an empty vector, and the very first line in main leads to undefined behavior since you’re trying to access item 0 (there is no such item). Live Example using operator [ ] Live Example showing what vector::at() does Note … Read more