I'm trying to find the maximum number of people at the base level after forming a human tower with the given number of people using recursion. In the human tower each level contains odd number of people and the top level contains only 1 person. The difference between any two adjacent levels is 2 persons I mean The number of people decrease from lower level to higher level by 2. Suppose if we have 4 persons then 3 will be at the bottom and 1 will be at top. if we have 6 persons then 3 will be at bottom and 1 will be at top and the remaining persons are discarded.
I tried the following code and I want to improve the code.
x=1
def human_pyramid(no_of_people):
global x
if(no_of_people<x):
return x-2
else:
no_of_people-=x
x+=2
return human_pyramid(no_of_people)
print(human_pyramid(20))
If input is 20 output should be 7. If input is 10 output should be 5. If input is 1 output should be 1.