In a class of 'N' students each student is asked to bring number of dishes as per their roll number for example student of roll number1 will bring 1 item, roll number 2 brings 2 items and so on. Write a python function calc(N) that takes integer value N and returns the total number of items brought by N students. Do not input() function for taking input ,specify it in fixed form and also don't use advanced data type(i.e. list, tuple,set, dictionary)
def number_dishes(n):
if n<0:
return 'Enter a positive number'
else:
return (n*(n+1))//2
n = 5
print(number_dishes(n))
Comments
Leave a comment