1.等差数列加法器:
a=0
n=1
x=int(input('从1加到:'))
y=int(input('等差值为:'))
while n<=x: a=a+n n=n+y
print(a)
2.等差数列奇加偶减器:
a=0 n=1 x=int(input('从1加到:')) y=int(input('等差值为:')) while n<=x: if n%2!=0: a=a+n else: a=a-n n=n+y print(a)