"""File: recursive_sum_prt.py Purpose: Find the sum of the first n positive integers using recursion Run: python recursive_sum_prt.py Input: A positive int n Output: The sum of the first n positive integers. This version also prints the recursive calls """ def rsum(val, indent): """ Use recursion to find the sum 1 + 2 + . . . + val""" indent = indent + " " print indent, "val =", val if val == 1: print indent, "val =", val, ", returning", val return val else: sum = val + rsum(val-1, indent) print indent, "val =", val, ", returning", sum return sum val = int(raw_input("Enter a whole number >= 1\n ")) print sum = rsum(val, "") print print "The sum of the first", val, "whole numbers is", sum