Math, asked by kunalmonethics, 5 hours ago

Python Programming 3: Calculate N Tetrahedral Number using a While loop only.​

Answers

Answered by dreamrob
2

Program:

n = int(input("Enter a number : "))

i = 1

previous = 0

while(i <= n):

   current = (int)((i * (i + 1)) / 2)

   current = current + previous

   print(current, end = "\t")

   previous = current

   i = i + 1

Output 1:

Enter a number : 5

1       4       10      20      35

Output 2:

Enter a number : 10

1       4       10      20      35      56      84      120     165     220

Similar questions