Back to list

Lantern Steps Sum

Lv.266@DevType ⌨️0 playsApr 27, 2026

A lantern path has steps 1..n. Add odd steps normally, but even steps as squares. Print the glowing total for n=7.

preview.python
Python
1n=7
2s=0
3for i in range(1,n+1):
4 if i%2==0:s+=i*i
5 else:s+=i
6print(s)

Custom problems are not included in rankings