Advertisement
SetKaung

Exercise

Dec 9th, 2023
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.25 KB | Software | 0 0
  1. i = int(input("Enter n:"))
  2.  
  3. count = 1
  4. total = 0
  5. result = ""
  6.  
  7. while count <= i:
  8.     total += count
  9.     if count < i:
  10.         result += str(count) + "+"
  11.     else:
  12.         result += str(count) + "="
  13.     count += 1
  14.  
  15. print(f"{result}{total}")
  16.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement