'Cyclelength using multiplenumber
I want to change the code where I can execute the code from the number 1 to 100. My code below only allows me to put in one number for n. But I want to put range 1-100 where the program will go through numbers 1 to 100.
def cyclelength(n,divs=[2],mult=3,inc=1,maxSize=-1):
result = []
while n not in result and len(result)!=maxSize:
result.append(n)
d = next((d for d in divs if n%d==0),None)
n = (n*mult+inc) if not d else n//d
return len(result)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
