Skip to content

Commit

Permalink
Only calculate stats when it is time to print
Browse files Browse the repository at this point in the history
  • Loading branch information
smcclennon committed Nov 27, 2019
1 parent 6945ed4 commit b6dc87f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Primer-C.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Primer Compatability version
# github.com/smcclennon/Primer
ver = '1.0.1C'
ver = '1.0.2C'
proj = 'Primer-C'


Expand Down Expand Up @@ -54,11 +54,10 @@
for i in range(2,num):
total=total+1
calculations=calculations+1
taskDuration=round(time.time()-taskStart, 2)
if num % i == 0: # If number is divisible by a number other than 1 or itself
invalid = 1

if invalid==0:
taskDuration=round(time.time()-taskStart, 2)
nR='true'
found=found+1
print(f'== {proj} v{ver} == Found Prime [#{found:,}]! ---> {num:,} <--- {calculations:,} calculations in {taskDuration} seconds --- Total Calculations: {total:,}')
Expand Down

0 comments on commit b6dc87f

Please sign in to comment.