Solved
Fixed totient function to not write past the end of the table
Easy!