This is my solution, use linkedlist, and find the math relationship of it