+0  
 
0
77
4
avatar+713 

Write your Python code to approximate the Golden Ratio by using this formula:

 

\(\phi_{n+1}=1+\frac{1}{\phi_n} \text{ and } \phi_0=1\)

 

a) Program the codes and prints the result after 20 iterations using the iteration method.
b) Program the codes by calling a function recursively. Print the result after calling the function
20 times.

 

 

 

please help!!! any help is appreciated!!! :)

 Jun 6, 2020
 #1
avatar+744 
0

I do java and c++, a little bit of python, though, but.....!

 Jun 6, 2020
 #2
avatar+713 
0

nice! so can you help? :)

lokiisnotdead  Jun 6, 2020
 #3
avatar
0

Part a: This is NOT in Python, but use as a guide:

 

i=1; g=(2#5)/2; g=1/g + 1; printg;i++;if(i<=20, goto2, 0)

PRINT 20 ITERATIONS:

1.894427191
1.527864045
1.654508497
1.604409105
1.623282426
1.616035746
1.618798193
1.617742226
1.618145452
1.617991416
1.61805025
1.618027777
1.618036361
1.618033083
1.618034335
1.618033857
1.618034039
1.618033969
1.618033996
1.618033986

 Jun 6, 2020
 #4
avatar+902 
0

I believe StackOverflow would be much more useful.

 

I don't do python normally, usually Java, C/C++, HTML, stuff like that.

 

I never studied the Golden Ratio so idk how it works but you might want something like this

 

for i in range(1,20):

 

(content)

 

Idk.

 Jun 6, 2020

22 Online Users