python return function not passing value -


this question has answer here:

while running programme, computes correct answer required. however, return function in if loop not return required answer instead returns "none". i've tried looking , i'm sure dumb i'm missing.

def is_prime(n):     #function tocheck if number prime     in range(2,n):         #print (i)         if n%i==0:             return false     return true  def gap(g,m,n):     #function find prime number     #pair prime gap "g"     print (is_prime(m),m)     print (is_prime(m+g),m+g)     if is_prime(m) , is_prime(m+g):         print ("this right answer : ",[m,g+m])         #value not returning         return [m,g+m]      elif g+m<n:         print("restart with",m+1)         gap(g,m+1,n)  print (gap(8,300,400)) 

i think need return gap(g,m+1,n). otherwise function not return result of recursive call.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -