能被3整除但不能被5整除

判断一个数n,能被3整除但不能被5整除,若满族条件,输出次数,否则终止程序。
我知道要用用while循环,但如何操作能被3整除但不能被5整除


i= 0
while(1):
    i += 1
    n = int(input())
    if n %3 == 0 and n%5 != 0:
        print("次数为{}".format(i))
        break
    else:
        continue

望采纳!


if n %3 == 0 and n%5 != 0:
  print(n)

n%3==0 and n%5!=0