prime calculator boy
This commit is contained in:
parent
290fcb97d0
commit
158001c04e
@ -5,9 +5,19 @@ from flask import Flask
|
|||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def hello_world():
|
def isprime():
|
||||||
target = os.environ.get('TARGET', 'World')
|
n = os.environ.get('TARGET', '42069')
|
||||||
return 'Hello {}!\n'.format(target)
|
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__":
|
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)))
|
||||||
|
Loading…
Reference in New Issue
Block a user