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.
python3defprime(num):ifnum==1:returnTrueelifnum>1:# check for factorsforiinrange(2,num):if(num%i)==0:# if factor is found, set flag to TruereturnTrue# break out of loopbreak# check if flag is TruereturnFalsedefprimeCount(n):# Write your code hereifn==1:return0else:mul=1count=0foriinrange(1,n+1):if(prime(i)==False):mul*=iifmul>n:breakelse:count+=1returncount
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Leonardo's Prime Factors
You are viewing a single comment's thread. Return to all comments →