Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
22
Task/Square-free-integers/Python/square-free-integers.py
Normal file
22
Task/Square-free-integers/Python/square-free-integers.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import math
|
||||
|
||||
def SquareFree ( _number ) :
|
||||
max = (int) (math.sqrt ( _number ))
|
||||
|
||||
for root in range ( 2, max+1 ): # Create a custom prime sieve
|
||||
if 0 == _number % ( root * root ):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def ListSquareFrees( _start, _end ):
|
||||
count = 0
|
||||
for i in range ( _start, _end+1 ):
|
||||
if True == SquareFree( i ):
|
||||
print ( "{}\t".format(i), end="" )
|
||||
count += 1
|
||||
|
||||
print ( "\n\nTotal count of square-free numbers between {} and {}: {}".format(_start, _end, count))
|
||||
|
||||
ListSquareFrees( 1, 100 )
|
||||
ListSquareFrees( 1000000000000, 1000000000145 )
|
||||
Loading…
Add table
Add a link
Reference in a new issue