Answer the question
In order to leave comments, you need to log in
How to solve a problem by recursive algorithm in python?
I can not solve the problem, you need to do it in python. The answer should be 164, I attached my wrong code and task.
k=0
c=0
def f(n):
if n <=5:
return n + 15
if n % 2 == 0 and n > 5:
return f(n//2)+n*n*n-1
if n % 2 != 0 and n>5:
return f(n-1) + 2*n*n+1
for i in range(1,1001):
x = f(i)
while x>0:
a = x % 10
if a == 8:
k = k + 1
x = x // 10
if k>=2:
c = c + 1
print(c)
input()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question