#include <iostream>
#include <inttypes.h>

uint64_t test_overflow(uint64_t start, uint64_t add, uint64_t check)
{
	uint64_t count = 0;
	uint64_t sum1 = start;
	uint64_t sum2 = start;
	do
	{
    	sum2 += sum1 += add;
    	count++;
    } while(sum1 < check && sum2 < check);
    return count;
}

int main() {
	std::cout << "Overflow of uint16_t after: " << test_overflow(0, UINT8_MAX, UINT16_MAX - UINT8_MAX) << " rounds (start value 0)." << std::endl;
	std::cout << "Overflow of uint32_t after: " << test_overflow(0, UINT16_MAX, UINT32_MAX - UINT16_MAX) << " rounds (start value 0)." << std::endl;
	std::cout << "Overflow of uint64_t after: " << test_overflow(0, UINT32_MAX, UINT64_MAX - UINT32_MAX) << " rounds (start value 0)." << std::endl;
	return 0;
}