bod1 = "1+2+3+...+n тооны нийлбэрийг ол"
bod2 = "2+4+6+...+2*n нийлбэрийг ол"
bod3 = '1*2 + 2*3 + 3*4 + 4*5 + 5*6 + ... + n*(n+1) нийлбэрийг ол'
print(bod1)
n = 1000
sum1 = 0
for i in range(1, n+1):
sum1 += i
print("1+2+3+...+n =", sum1)
print('\n')
print(bod2)
n = 1000
sum2 = 0
for i in range(2, n+1, 2):
sum2 += i
print("2+4+6+...+2*n =", sum2)
print('\n')
print(bod3)
n = 1000
sum3 = 0
for i in range(1, n+1):
sum3 += i*(i + 1)
print("1*2 + 2*3 + 3*4 + 4*5 + 5*6 + ... + n*(n+1) =", sum3)
No comments:
Post a Comment