Skip to content

Commit

Permalink
Update factors.py
Browse files Browse the repository at this point in the history
Made the code more efficient.
  • Loading branch information
Ahish9009 authored Oct 1, 2018
1 parent b300b4c commit b57bc39
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions factors.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import math

print('The factors of the number you type when prompted will be displayed')
a = int(input('Type now // '))
b = a
while b > 0:
b = 1
while b <= math.sqrt(a):
if a % b == 0:
print(b)
b -= 1
print("A factor of the number is ", b)
print("A factor of the number is ", int(a/b))
b += 1

0 comments on commit b57bc39

Please sign in to comment.