diff --git a/isprime-python/.idea/.gitignore b/isprime-python/.idea/.gitignore new file mode 100644 index 0000000..5c98b42 --- /dev/null +++ b/isprime-python/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml \ No newline at end of file diff --git a/isprime-python/.idea/inspectionProfiles/profiles_settings.xml b/isprime-python/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/isprime-python/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/isprime-python/.idea/isprime-python.iml b/isprime-python/.idea/isprime-python.iml new file mode 100644 index 0000000..c30daf7 --- /dev/null +++ b/isprime-python/.idea/isprime-python.iml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/isprime-python/.idea/libraries/R_User_Library.xml b/isprime-python/.idea/libraries/R_User_Library.xml new file mode 100644 index 0000000..71f5ff7 --- /dev/null +++ b/isprime-python/.idea/libraries/R_User_Library.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/isprime-python/.idea/misc.xml b/isprime-python/.idea/misc.xml new file mode 100644 index 0000000..8656114 --- /dev/null +++ b/isprime-python/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/isprime-python/.idea/modules.xml b/isprime-python/.idea/modules.xml new file mode 100644 index 0000000..b1716f3 --- /dev/null +++ b/isprime-python/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/isprime-python/.idea/vcs.xml b/isprime-python/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/isprime-python/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/isprime-python/app.py b/isprime-python/app.py index 51672d3..a46d9b1 100644 --- a/isprime-python/app.py +++ b/isprime-python/app.py @@ -4,20 +4,20 @@ from flask import Flask app = Flask(__name__) + @app.route('/') 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" + num = os.environ.get('TARGET', '107107') + if num > 1: + # check for factors + for i in range(2, num): + if (num % i) == 0: + return "not prime" + else: + return "not prime" + + else: + print(num, "is not a prime number") 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)))