We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
My code is passing 0 and 1 test cases but failing reaminig all test cases can anyone one help me out.
My code is absolutely fine but i don't know why its failing test cases.
def prime(k):
for i in range(2,k):
if k%i==0:
return False
return True
n,m=list(map(int,input().split()))
l=[i for i in range(1,n+1)]
for i in range(1,n+1):
for j in range(2,i):
if prime(j):
if i%(j**m)==0:
l.remove(i)
else:
continue
print(len(l))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #193: Squarefree Numbers
You are viewing a single comment's thread. Return to all comments →
My code is passing 0 and 1 test cases but failing reaminig all test cases can anyone one help me out. My code is absolutely fine but i don't know why its failing test cases. def prime(k): for i in range(2,k): if k%i==0: return False return True
n,m=list(map(int,input().split())) l=[i for i in range(1,n+1)] for i in range(1,n+1): for j in range(2,i): if prime(j): if i%(j**m)==0: l.remove(i) else: continue print(len(l))