Program to calculate nth node in a linked list