Question: - JoynerConjecture.py Submit Run Grades Reset 1 #The Joyner Conjecture is a not-at-all famous mathematical Console output will be displayed here 2 #seriesinspired by the

 - JoynerConjecture.py Submit Run Grades Reset 1 #The Joyner Conjecture is

- JoynerConjecture.py Submit Run Grades Reset 1 #The Joyner Conjecture is a not-at-all famous mathematical Console output will be displayed here 2 #seriesinspired by the Collatz Conjecture for use in this 3 #class 4# 5 #The Joyner Conjecture proceeds as follows: 7 #Start with any number.. If the number is divisible by 3, 8 #divide it by 3, Otherwise, add 2 to the number. Eventually, 9 #no matter what number you begin with, this series will run le #into 1 or 2. If it runs into I, it will repeat 1-3 forever 11 #If it runs into 2, it will repeat 2-4-6 forever. 12 # 13 #For example, imagine we started with the number 5: 14 #5 is not divisible by 3, so 5 + 2-7 15 #7 is not divisible by 3, so 7 + 2-9 16 #9 is divisible by 3, so 9 / 3 3 17 #3 is divisible by 3, so 3 / 3-1 18 # 19 #Start with 5. this sequence converges on 1 in 4 iterations: 2e #5-> 7, 7*)9,9-> 3, 3*)1. 21# 22 #Write a function called joyner. joyner should have one 23 #parameter, an integer. It should return the number of 24 #iterations required to reach either 1 or 2 for the first 25 #time 26 27 28 #Add your code here! 29 def joyner(a_integer): 3e 31 32 count while integer=1 integer>=2 : a if a-integer else: count+a1 or a % 3--e a integer/3 a_integer+2 34 35 36 37 38 39 40 return count 42

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!