Fix integer overflow problem by switching to long for the large iteration numbers (Raj-Level operations).