Блог пользователя touhidurrr

Автор touhidurrr, история, 3 года назад, По-английски

Hi. I wanted to make an example of splitting up recursive functions on python because python returns error if the level of a recursive function gets to deep. And somehow got this funny thing that returns the higest power of 2 from 1 to n given n. Not sure how exactly it happens. Can anyone explain it Mathematically maybe?

def example(n):
  if n < 2: return 1
  return example(n/2) + example(n/2)

def example2(n):
  if n < 2: return 1
  return example2(n/4) + example2(n/4) + example2(n/4) + example2(n/4)

print(example(100), example2(100))
# prints 64 64

print(example(1600), example2(1600))
# prints 1024 1024

Полный текст и комментарии »

  • Проголосовать: нравится
  • -3
  • Проголосовать: не нравится

Автор touhidurrr, история, 5 лет назад, По-английски

Somehow in my profile, the date that I had registered has been changed to 1/1/1970 and is showing that I had joined the cf 50 years ago.

Someone told me that he had experienced the same once and it was automatically fixed.

What is going wrong actually.......?

UPDATE: The problem fixed automatically, reasons unknown.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +12
  • Проголосовать: не нравится