My code for fundamental problem