prime calculator boy
This commit is contained in:
		@@ -5,9 +5,19 @@ from flask import Flask
 | 
			
		||||
app = Flask(__name__)
 | 
			
		||||
 | 
			
		||||
@app.route('/')
 | 
			
		||||
def hello_world():
 | 
			
		||||
    target = os.environ.get('TARGET', 'World')
 | 
			
		||||
    return 'Hello {}!\n'.format(target)
 | 
			
		||||
def isprime():
 | 
			
		||||
  n = os.environ.get('TARGET', '42069')
 | 
			
		||||
  if n == 2 or n == 3: return "Prime"
 | 
			
		||||
  if n < 2 or n%2 == 0: return "Not Prime"
 | 
			
		||||
  if n < 9: return "Prime"
 | 
			
		||||
  if n%3 == 0: return "Not Prime"
 | 
			
		||||
  r = int(n**0.5)
 | 
			
		||||
  f = 5
 | 
			
		||||
  while f <= r:
 | 
			
		||||
    if n%f == 0: return "Not Prime"
 | 
			
		||||
    if n%(f+2) == 0: return "Not Prime"
 | 
			
		||||
    f +=6
 | 
			
		||||
  return "Prime"
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
    app.run(debug=True,host='0.0.0.0',port=int(os.environ.get('PORT', 8080)))
 | 
			
		||||
  app.run(debug=True,host='0.0.0.0',port=int(os.environ.get('PORT', 8080)))
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user