2021-02-08 18:29:13 +01:00
#! /usr/bin/env python3
import sys
import collatz
2021-02-20 23:57:18 +01:00
usage = ' usage: collatzSearch [digits] ([startDigits]) outputs the lenght of the collatz sequence for every number less than 10^digits, starting with 10^startDidgits. '
nextNumber = 1
2021-02-08 18:29:13 +01:00
if len ( sys . argv ) < 2 :
print ( usage )
sys . exit ( )
digits = sys . argv [ 1 ]
try :
digits = int ( digits )
except :
print ( usage )
sys . exit ( )
2021-02-20 23:57:18 +01:00
if len ( sys . argv ) > = 3 :
try :
nextNumber = 10 * * int ( sys . argv [ 2 ] )
except :
print ( usage )
sys . exit ( )
2021-02-08 18:29:13 +01:00
maxNumber = 10 * * digits
while nextNumber < maxNumber :
print ( ' collatz length of ' + str ( nextNumber ) + ' is: \n ' + str ( collatz . seqenceLength ( nextNumber ) ) )
nextNumber + = 1