def isPrime(num,div=2):
if(num==div):
return True
elif(num % div == 0):
return False
else:
return isPrime(num,div+1)
birinci2012 0 Newbie Poster
Recommended Answers
Jump to PostProbably the worst
isPrime()
function I've ever seen. If num is above 1000000, you are going to stack 1000000 recursive calls ! Python comes with a recursion limit>>> import sys >>> sys.getrecursionlimit() 1000
which means that your code will fail. The limit can be changed, …
All 2 Replies
Gribouillis 1,391 Programming Explorer Team Colleague
slate 241 Posting Whiz in Training
Gribouillis commented: ugly code :) +14
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.