#include <iostream>
#include <cmath>
#include <windows.h>
using namespace std;
int n_before = 5;
int main()
{
int numberofwritten = 3;
int numberofwritten_before = 0;
__int64 data[999];
data[0] = 0;
data[1] = 1;
data[2] = 1;
data[3] = 1;
__int64 three = 1;
for (__int64 i = 1; i <= n_before; i++)
{
numberofwritten++;
three*=3;
data[numberofwritten] = three;
numberofwritten_before = numberofwritten;
for (__int64 j = 1; j < numberofwritten_before; j++)
{
numberofwritten++;
data[numberofwritten] = data[j];
}
}
for (int i = 0; i <= 900; i++)
{
cout << i << " equals " << data[i] << endl;
}
}
When you compile this, after 128 you get max value of int64__
(-3689348814741910324). What is wrong?
Further, when I compile this in CodeBlocks (instead of Visual Studio), I get different numbers after 128 (but still wrong).
The code is meant to make a sequence of 1113111 then 111311191113111 and so on; basically same 111 (3^1) after that 111 (thing that was before) and after that (3^2) and what was before and so on (exponent increments with every iteration).