Calculate the sum

can you please explain me the approach and provide me the code

hi @bakshianjali49,
refer https://ide.codingblocks.com/s/662778