# -*- coding: utf-8 -*-
"""
Created on Tue Sep 22 14:46:15 2020

@author: Sim
"""

# recursive1.py
def sum2n(x,p):
    if x == 1:
        return 1
    else:
        return x ** p + sum2n(x-1, p)

nn = int(input("Type in n for sum 1 to n^p: "))
pp = int(input("Type in p for sum 1 to n^p: "))
print(sum2n(nn, pp))