File tree Expand file tree Collapse file tree 1 file changed +3
-6
lines changed
Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change @@ -75,10 +75,7 @@ def is_prime(n: int) -> bool:
7575 return True
7676 if n % 2 == 0 :
7777 return False
78- for i in range (3 , int (math .sqrt (n )) + 1 , 2 ):
79- if n % i == 0 :
80- return False
81- return True
78+ return all (n % i != 0 for i in range (3 , int (math .sqrt (n )) + 1 , 2 ))
8279
8380
8481def is_perfect_power (n : int ) -> tuple [int , int ] | None :
@@ -463,7 +460,7 @@ def factor_with_explanation(n: int) -> None:
463460 print (" - Successfully found factors!" )
464461 print ()
465462 print ("=" * 60 )
466- print (f"RESULT: { n } = { factors [0 ]} × { factors [1 ]} " )
463+ print (f"RESULT: { n } = { factors [0 ]} * { factors [1 ]} " )
467464 print ("=" * 60 )
468465 else :
469466 print (" - Failed to find factors" )
@@ -491,7 +488,7 @@ def factor_with_explanation(n: int) -> None:
491488 result = shors_algorithm (num )
492489 if result :
493490 p , q = result
494- print (f"{ num :4d} = { p } × { q } " )
491+ print (f"{ num :4d} = { p } * { q } " )
495492 else :
496493 print (f"{ num :4d} = Failed to factor" )
497494
You can’t perform that action at this time.
0 commit comments