V
V
vladpenziy132020-09-20 18:00:21
Python
vladpenziy13, 2020-09-20 18:00:21

How to write it in a loop?

5f676e563b396767794919.png
I can't figure out how to write the code

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
szafranji, 2020-09-20
@vladpenziy13

import math
a_n_prev = x
for i in range(2, n):
    a_n = 3 + 1/(2**n) * math.pow(math.sin(a_n_prev - x), 2) #a_n_prev = a_n-1
    print(a_n)
    a_n_prev = a_n

Xs, is this correct, correct if anything.

D
dmshar, 2020-09-20
@dmshar

import math
x=0.1
N=20
a=[x]
for i in range(2,N):
    a.append(3+(1/(2**i))*(math.sin(a[-1]-x))**2)
print (a)

Only as long as you run after every bunch with questions to the forum, you will not become a programmer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question