![](/img/trans.png)
[英]python program, Write a program to print first x terms of the series 3N + 2 which are not multiples of 4
[英]Write a program to print the sum of 1 to n. While calculating sum omits the numbers which are multiples of x. Note :Use the concept of continue
请帮我解决这个问题,我不能省略多个 x
For i in range(0,n+1):
if(i%6==0):
Continue
Sum=sum+i
print(int(sum))
print(sum)
for
和continue
等关键字不应大写:
如果您试图找到不是 x 倍数的数字的总和,那么您可以试试这个:
total = 0
n = int(input("Enter n: "))
x = int(input("Enter x: "))
for i in range(0,n+1):
if(i%x==0):
continue
total += i
print(total)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.