{"id":260124,"date":"2015-06-25T16:30:02","date_gmt":"2015-06-25T12:30:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=260124"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=260124","title":{"rendered":"5 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438: \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435"},"content":{"rendered":"<br \/>\n<h4>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430\u043c \u0447\u0438\u0441\u043b\u0430 \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0436\u0435 \u043f\u043e\u0434\u043d\u0430\u0434\u043e\u0435\u0441\u0442\u044c. \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432\u0435\u0437\u0434\u0435. \u0412\u0441\u0451 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u044d\u0442\u0438 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438. \u0410 \u0435\u0449\u0451 \u043e\u043d\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041d\u043e \u043d\u0430\u0434\u043e \u043b\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0438\u0445 \u0442\u0430\u043a \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435? \u041d\u0435 \u043d\u0430\u0434\u043e. \u041d\u0438 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f, \u043d\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u043c\u0438. \u0418 \u043d\u0435 \u0437\u0430\u043c\u043a\u043d\u0443\u0442\u0430\u044f \u0444\u043e\u0440\u043c\u0443\u043b\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0430\u044f \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0437\u0430\u043f\u044f\u0442\u043e\u0439. \u0421\u0435\u0439\u0447\u0430\u0441 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u041d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0439\u0434\u0451\u043c\u0441\u044f \u043f\u043e \u0432\u0441\u0435\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u041a\u043e\u0434 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f Python 3, \u0445\u043e\u0442\u044f \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u0434\u0442\u0438 \u0438 \u043d\u0430 Python 2.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u2013 \u043d\u0430\u043f\u043e\u043c\u043d\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435:<\/p>\n<p>  F<sub>n<\/sub>= F<sub>n-1<\/sub>+ F<sub>n-2<\/sub><\/p>\n<p>  \u0438 F<sub>1<\/sub>= F<sub>2<\/sub>=1.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u0417\u0430\u043c\u043a\u043d\u0443\u0442\u0430\u044f \u0444\u043e\u0440\u043c\u0443\u043b\u0430<\/h4>\n<p>  \u041f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0434\u0435\u0442\u0430\u043b\u0438, \u043d\u043e \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0435 \u043c\u043e\u0433\u0443\u0442 <a href=\"http:\/\/en.wikipedia.org\/wiki\/Fibonacci_number#Closed-form_expression\">\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u044b\u0432\u043e\u0434\u043e\u043c \u0444\u043e\u0440\u043c\u0443\u043b\u044b<\/a>. \u0418\u0434\u0435\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u0438\u0439 x, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e F<sub>n<\/sub> = x<sup>n<\/sup>, \u0430 \u0437\u0430\u0442\u0435\u043c \u043d\u0430\u0439\u0442\u0438 x.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/595\/c24\/a05\/595c24a057bb4f6ebc5f52643f9be2f5.png\"\/><\/p>\n<p>  \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/520\/b93\/744\/520b937449284d639bfef75fe9d9d580.PNG\"\/><\/p>\n<p>  \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0435\u043c x<sup>n-2<\/sup><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/0bf\/24b\/b39\/0bf24bb39c9543d1a64c192d96cb9d2b.PNG\"\/><\/p>\n<p>  \u0420\u0435\u0448\u0430\u0435\u043c \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u043e\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/701\/b06\/9d2\/701b069d29154ff3910e74d32830e3fd.PNG\"\/><\/p>\n<p>  \u041e\u0442\u043a\u0443\u0434\u0430 \u0438 \u0440\u0430\u0441\u0442\u0451\u0442 \u00ab\u0437\u043e\u043b\u043e\u0442\u043e\u0435 \u0441\u0435\u0447\u0435\u043d\u0438\u0435\u00bb \u03d5=(1+\u221a5)\/2. \u041f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0432 \u0435\u0449\u0451 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/e37\/e6d\/a39\/e37e6da397144b688b46b276293b373a.PNG\"\/><\/p>\n<p>  \u0447\u0442\u043e \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f F<sub>n<\/sub>.<\/p>\n<pre><code class=\"python\">from __future__ import division import math  def fib(n):     SQRT5 = math.sqrt(5)     PHI = (SQRT5 + 1) \/ 2     return int(PHI ** n \/ SQRT5 + 0.5) <\/code><\/pre>\n<p>  \u0425\u043e\u0440\u043e\u0448\u0435\u0435:<br \/>  \u0411\u044b\u0441\u0442\u0440\u043e \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043b\u044f \u043c\u0430\u043b\u044b\u0445 n<br \/>  \u041f\u043b\u043e\u0445\u043e\u0435:<br \/>  \u0422\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0437\u0430\u043f\u044f\u0442\u043e\u0439. \u0414\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 n \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c.<br \/>  \u0417\u043b\u043e\u0435:<br \/>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f F<sub>n<\/sub> \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0441 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f, \u043d\u043e \u0443\u0440\u043e\u0434\u043b\u0438\u0432\u043e \u2014 \u0441 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u0439.<\/p>\n<h4>\u0420\u0435\u043a\u0443\u0440\u0441\u0438\u044f<\/h4>\n<p>  \u0421\u0430\u043c\u043e\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b \u0443\u0436\u0435 \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437 \u0432\u0438\u0434\u0435\u043b\u0438 \u2013 \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f. \u041f\u043e\u0432\u0442\u043e\u0440\u044e \u0435\u0433\u043e \u0435\u0449\u0451 \u0440\u0430\u0437, \u0434\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0442\u044b. \u0412 Python \u0435\u0451 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443:<\/p>\n<pre><code class=\"python\">fib = lambda n: fib(n - 1) + fib(n - 2) if n &gt; 2 else 1 <\/code><\/pre>\n<p>  \u0425\u043e\u0440\u043e\u0448\u0435\u0435:<br \/>  \u041e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0430\u044f \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435<br \/>  \u041f\u043b\u043e\u0445\u043e\u0435: <br \/>  \u042d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 n \u043e\u0447\u0435\u043d\u044c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e<br \/>  \u0417\u043b\u043e\u0435:<br \/>  \u041f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u0442\u0435\u043a\u0430<\/p>\n<h4>\u0417\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u0435<\/h4>\n<p>  \u0423 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0435\u0439 \u0435\u0441\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f. \u041a\u043e\u0433\u0434\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f fib(n), \u0442\u043e \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f fib(n-1) \u0438 fib(n-2). \u041d\u043e \u043a\u043e\u0433\u0434\u0430 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f fib(n-1), \u043e\u043d\u0430 \u0441\u043d\u043e\u0432\u0430 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u0430\u0435\u0442 fib(n-2) \u2013 \u0442\u043e \u0435\u0441\u0442\u044c, fib(n-2) \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0434\u0432\u0430\u0436\u0434\u044b. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f, \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e fib(n-3) \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u0430\u043d\u0430 \u0442\u0440\u0438\u0436\u0434\u044b, \u0438 \u0442.\u0434. \u0421\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0439.<\/p>\n<p>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0438\u0445 \u0441\u043d\u043e\u0432\u0430. \u0412\u0440\u0435\u043c\u044f \u0438 \u043f\u0430\u043c\u044f\u0442\u044c \u0443 \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0441\u0445\u043e\u0434\u0443\u044e\u0442\u0441\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u0412 \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432.<\/p>\n<pre><code class=\"python\">M = {0: 0, 1: 1}  def fib(n):     if n in M:         return M[n]     M[n] = fib(n - 1) + fib(n - 2)     return M[n] <\/code><\/pre>\n<p>  (\u0412 Python \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430, functools.lru_cache.)<\/p>\n<p>  \u0425\u043e\u0440\u043e\u0448\u0435\u0435:<br \/>  \u041f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044e \u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u0435\u043c. \u041f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0435, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u0442\u0440\u0430\u0442\u0438\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0430\u043c\u044f\u0442\u0438.<br \/>  \u041f\u043b\u043e\u0445\u043e\u0435:<br \/>  \u0422\u0440\u0430\u0442\u0438\u0442 \u043c\u043d\u043e\u0433\u043e \u043f\u0430\u043c\u044f\u0442\u0438<br \/>  \u0417\u043b\u043e\u0435: <br \/>  \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u0442\u0435\u043a\u0430, \u043a\u0430\u043a \u0438 \u0443 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438<\/p>\n<h4>\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h4>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u0435\u043c \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u043d\u0435 \u0432\u0441\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0432\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445. \u041a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e, \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u0441 fib(n) \u0438 \u0438\u0434\u0442\u0438 \u043d\u0430\u0437\u0430\u0434, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u0441 fib(0) \u0438 \u0438\u0434\u0442\u0438 \u0432\u043f\u0435\u0440\u0451\u0434. \u0423 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435, \u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u2013 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435. \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0435\u0449\u0451 \u0432\u044b\u0448\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0442\u0443\u0442 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u0441 \u044d\u0442\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0430. \u0418 \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u043e\u0449\u0435.<\/p>\n<p>  \u042d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<pre><code class=\"python\">def fib(n):     a = 0     b = 1     for __ in range(n):         a, b = b, a + b     return a <\/code><\/pre>\n<p>  \u0425\u043e\u0440\u043e\u0448\u0435\u0435:<br \/>  \u0411\u044b\u0441\u0442\u0440\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0434\u043b\u044f \u043c\u0430\u043b\u044b\u0445 n, \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043e\u0434<br \/>  \u041f\u043b\u043e\u0445\u043e\u0435:<br \/>  \u0412\u0441\u0451 \u0435\u0449\u0451 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<br \/>  \u0417\u043b\u043e\u0435:<br \/>  \u0414\u0430 \u043e\u0441\u043e\u0431\u043e \u043d\u0438\u0447\u0435\u0433\u043e.<\/p>\n<h4>\u041c\u0430\u0442\u0440\u0438\u0447\u043d\u0430\u044f \u0430\u043b\u0433\u0435\u0431\u0440\u0430<\/h4>\n<p>  \u0418, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043d\u0430\u0438\u043c\u0435\u043d\u0435\u0435 \u043e\u0441\u0432\u0435\u0449\u0430\u0435\u043c\u043e\u0435, \u043d\u043e \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0433\u0440\u0430\u043c\u043e\u0442\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0435\u0435 \u043a\u0430\u043a \u0432\u0440\u0435\u043c\u044f, \u0442\u0430\u043a \u0438 \u043f\u0430\u043c\u044f\u0442\u044c. \u0415\u0433\u043e \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u043d\u0430 \u043b\u044e\u0431\u0443\u044e \u0433\u043e\u043c\u043e\u0433\u0435\u043d\u043d\u0443\u044e \u043b\u0438\u043d\u0435\u0439\u043d\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u0418\u0434\u0435\u044f \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u0430\u0442\u0440\u0438\u0446. \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/c7b\/94d\/4c3\/c7b94d4c351a4719a3bafedff4eeb808.PNG\"\/><\/p>\n<p>  \u0410 \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/c12\/ac2\/4c8\/c12ac24c87f045688714c416752afc40.PNG\"\/><\/p>\n<p>  \u0414\u0432\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f x, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u043d\u0430\u043c\u0438 \u0440\u0430\u043d\u0435\u0435, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0434\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u043e \u0441\u043e\u0431\u043e\u044e \u0437\u043e\u043b\u043e\u0442\u043e\u0435 \u0441\u0435\u0447\u0435\u043d\u0438\u0435, \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u044b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0449\u0451 \u043e\u0434\u043d\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0432\u044b\u0432\u043e\u0434\u0430 \u0437\u0430\u043c\u043a\u043d\u0443\u0442\u043e\u0439 \u0444\u043e\u0440\u043c\u0443\u043b\u044b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0433\u043e \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0438 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0430\u043b\u0433\u0435\u0431\u0440\u044b.<\/p>\n<p>  \u0422\u0430\u043a \u0447\u0435\u043c \u0436\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0442\u0430\u043a\u0430\u044f \u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u043a\u0430? \u0422\u0435\u043c, \u0447\u0442\u043e \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0437\u0430 \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0432\u0440\u0435\u043c\u044f. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 <a href=\"http:\/\/sahandsaba.com\/cryptography-rsa-part-1.html\">\u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442<\/a>. \u0421\u0443\u0442\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/a88\/dfc\/655\/a88dfc6558824458ad8053cd850ff3ac.PNG\"\/><\/p>\n<p>  \u0433\u0434\u0435 \u043f\u0435\u0440\u0432\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0447\u0451\u0442\u043d\u044b\u0445 A, \u0432\u0442\u043e\u0440\u043e\u0435 \u0434\u043b\u044f \u043d\u0435\u0447\u0451\u0442\u043d\u044b\u0445. \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u0430\u0442\u0440\u0438\u0446, \u0438 \u0432\u0441\u0451 \u0433\u043e\u0442\u043e\u0432\u043e. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434. \u042f \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043b \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e pow, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0435\u0451 \u043f\u0440\u043e\u0449\u0435 \u043f\u043e\u043d\u044f\u0442\u044c. \u0418\u0442\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0442\u0443\u0442.<\/p>\n<pre><code class=\"python\">def pow(x, n, I, mult):     &quot;&quot;&quot;     \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 x \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 n. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442, \u0447\u0442\u043e I \u2013 \u044d\u0442\u043e \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f      \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0430\u0435\u0442\u0441\u044f \u0441 mult, \u0430 n \u2013 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435     &quot;&quot;&quot;     if n == 0:         return I     elif n == 1:         return x     else:         y = pow(x, n \/\/ 2, I, mult)         y = mult(y, y)         if n % 2:             y = mult(x, y)         return y   def identity_matrix(n):     &quot;&quot;&quot;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 n \u043d\u0430 n&quot;&quot;&quot;     r = list(range(n))     return [[1 if i == j else 0 for i in r] for j in r]   def matrix_multiply(A, B):     BT = list(zip(*B))     return [[sum(a * b                  for a, b in zip(row_a, col_b))             for col_b in BT]             for row_a in A]   def fib(n):     F = pow([[1, 1], [1, 0]], n, identity_matrix(2), matrix_multiply)     return F[0][1] <\/code><\/pre>\n<p>  \u0425\u043e\u0440\u043e\u0448\u0435\u0435:<br \/>  \u0424\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0451\u043c \u043f\u0430\u043c\u044f\u0442\u0438, \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0432\u0440\u0435\u043c\u044f<br \/>  \u041f\u043b\u043e\u0445\u043e\u0435:<br \/>  \u041a\u043e\u0434 \u043f\u043e\u0441\u043b\u043e\u0436\u043d\u0435\u0435<br \/>  \u0417\u043b\u043e\u0435:<br \/>  \u041f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043c\u0430\u0442\u0440\u0438\u0446\u0430\u043c\u0438, \u0445\u043e\u0442\u044f \u043e\u043d\u0438 \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0438 \u043f\u043b\u043e\u0445\u0438<\/p>\n<h4>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0431\u044b\u0441\u0442\u0440\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f<\/h4>\n<p>  \u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0441\u0442\u043e\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u044b. \u0415\u0441\u043b\u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0438\u0445 \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0437\u043d\u0430\u043a\u043e\u0432 \u0432 \u0447\u0438\u0441\u043b\u0435 n, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f, \u0447\u0442\u043e \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u043e, \u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u2013 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e. \u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u2013 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 fib(10 ** 6), \u0447\u0438\u0441\u043b\u0430, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0432\u0443\u0445\u0441\u043e\u0442 \u0442\u044b\u0441\u044f\u0447 \u0437\u043d\u0430\u043a\u043e\u0432.<\/p>\n<p>  n = 10 ** 6<br \/>  \u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c fib_matrix: \u0443 fib(n) \u0432\u0441\u0435\u0433\u043e 208988 \u0446\u0438\u0444\u0440, \u0440\u0430\u0441\u0447\u0451\u0442 \u0437\u0430\u043d\u044f\u043b 0.24993 \u0441\u0435\u043a\u0443\u043d\u0434.<br \/>  \u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c fib_dynamic: \u0443 fib(n) \u0432\u0441\u0435\u0433\u043e 208988 \u0446\u0438\u0444\u0440, \u0440\u0430\u0441\u0447\u0451\u0442 \u0437\u0430\u043d\u044f\u043b 11.83377 \u0441\u0435\u043a\u0443\u043d\u0434.<\/p>\n<hr\/>\n<h4>\u0422\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f<\/h4>\n<p>  \u041d\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043a\u0430\u0441\u0430\u044f\u0441\u044c \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435 \u043a\u043e\u0434\u0430, \u0434\u0430\u043d\u043d\u043e\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435 \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u0438\u043c\u0435\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0433\u0440\u0430\u0444:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5c9\/206\/c1f\/5c9206c1fa711d2fa28c7b07e5954e12.png\" alt=\"image\"\/><\/p>\n<p>  \u041f\u043e\u0434\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0443\u0442\u0435\u0439 \u0434\u043b\u0438\u043d\u044b n \u043e\u0442 A \u0434\u043e B. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f n = 1 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043e\u0434\u0438\u043d \u043f\u0443\u0442\u044c, 1. \u0414\u043b\u044f n = 2 \u0443 \u043d\u0430\u0441 \u043e\u043f\u044f\u0442\u044c \u0435\u0441\u0442\u044c \u043e\u0434\u0438\u043d \u043f\u0443\u0442\u044c, 01. \u0414\u043b\u044f n = 3 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u043f\u0443\u0442\u0438, 001 \u0438 101. \u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0443\u0442\u0435\u0439 \u0434\u043b\u0438\u043d\u044b n \u043e\u0442 \u0410 \u0434\u043e \u0412 \u0440\u0430\u0432\u043d\u043e \u0432 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 F<sub>n<\/sub>. \u0417\u0430\u043f\u0438\u0441\u0430\u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u0433\u0440\u0430\u0444\u0430, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0442\u0430\u043a\u0443\u044e \u0436\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u044b\u043b\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432\u044b\u0448\u0435. \u042d\u0442\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0437 \u0442\u0435\u043e\u0440\u0438\u0438 \u0433\u0440\u0430\u0444\u043e\u0432, \u0447\u0442\u043e \u043f\u0440\u0438 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u0410, \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0432 \u0410<sup>n<\/sup> \u2014 \u044d\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0443\u0442\u0435\u0439 \u0434\u043b\u0438\u043d\u044b n \u0432 \u0433\u0440\u0430\u0444\u0435 (<a href=\"http:\/\/mat.unideb.hu\/media\/horvath-gabor\/publications\/gwh2.pdf\">\u043e\u0434\u043d\u0430 \u0438\u0437 \u0437\u0430\u0434\u0430\u0447, \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u0432\u0448\u0438\u0445\u0441\u044f <\/a>\u0432 \u0444\u0438\u043b\u044c\u043c\u0435 \u00ab\u0423\u043c\u043d\u0438\u0446\u0430 \u0423\u0438\u043b\u043b \u0425\u0430\u043d\u0442\u0438\u043d\u0433\u00bb).<\/p>\n<p>  \u041f\u043e\u0447\u0435\u043c\u0443 \u043d\u0430 \u0440\u0451\u0431\u0440\u0430\u0445 \u0441\u0442\u043e\u044f\u0442 \u0442\u0430\u043a\u0438\u0435 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f? \u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043f\u0440\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0438 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u043d\u0430 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0432 \u043e\u0431\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0443\u0442\u0435\u0439 \u043d\u0430 \u0433\u0440\u0430\u0444\u0435, \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043d\u0435\u0447\u0442\u043e \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c &quot;<a href=\"http:\/\/en.wikipedia.org\/wiki\/Subshift_of_finite_type\">\u043f\u043e\u0434\u0441\u0434\u0432\u0438\u0433\u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430<\/a>&quot;, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0435 \u0441\u043e\u0431\u043e\u0439 \u0442\u0438\u043f \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441\u0438\u043c\u0432\u043e\u043b\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0438. \u041a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0441\u0434\u0432\u0438\u0433 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d, \u043a\u0430\u043a \u00ab\u0441\u0434\u0432\u0438\u0433 \u0437\u043e\u043b\u043e\u0442\u043e\u0433\u043e \u0441\u0435\u0447\u0435\u043d\u0438\u044f\u00bb, \u0438 \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u00ab\u0437\u0430\u043f\u0440\u0435\u0449\u0451\u043d\u043d\u044b\u0445 \u0441\u043b\u043e\u0432\u00bb {11}. \u0418\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u0432 \u043e\u0431\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u043d\u0438\u043a\u0430\u043a\u0438\u0435 \u043f\u0430\u0440\u044b \u0438\u0437 \u043d\u0438\u0445 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u043c\u0435\u0436\u043d\u044b\u043c\u0438. \u0422\u043e\u043f\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u044d\u043d\u0442\u0440\u043e\u043f\u0438\u044f \u044d\u0442\u043e\u0439 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0440\u0430\u0432\u043d\u0430 \u0437\u043e\u043b\u043e\u0442\u043e\u043c\u0443 \u0441\u0435\u0447\u0435\u043d\u0438\u044e \u03d5. \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043e\u0431\u043b\u0430\u0441\u0442\u044f\u0445 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438.   \t<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/261159\/\"> http:\/\/habrahabr.ru\/post\/261159\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<br \/>\n<h4>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430\u043c \u0447\u0438\u0441\u043b\u0430 \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0436\u0435 \u043f\u043e\u0434\u043d\u0430\u0434\u043e\u0435\u0441\u0442\u044c. \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432\u0435\u0437\u0434\u0435. \u0412\u0441\u0451 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u044d\u0442\u0438 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438. \u0410 \u0435\u0449\u0451 \u043e\u043d\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041d\u043e \u043d\u0430\u0434\u043e \u043b\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0438\u0445 \u0442\u0430\u043a \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435? \u041d\u0435 \u043d\u0430\u0434\u043e. \u041d\u0438 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f, \u043d\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u043c\u0438. \u0418 \u043d\u0435 \u0437\u0430\u043c\u043a\u043d\u0443\u0442\u0430\u044f \u0444\u043e\u0440\u043c\u0443\u043b\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0430\u044f \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0437\u0430\u043f\u044f\u0442\u043e\u0439. \u0421\u0435\u0439\u0447\u0430\u0441 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u041d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0439\u0434\u0451\u043c\u0441\u044f \u043f\u043e \u0432\u0441\u0435\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u041a\u043e\u0434 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f Python 3, \u0445\u043e\u0442\u044f \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u0434\u0442\u0438 \u0438 \u043d\u0430 Python 2.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u2013 \u043d\u0430\u043f\u043e\u043c\u043d\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435:<\/p>\n<p>  F<sub>n<\/sub>= F<sub>n-1<\/sub>+ F<sub>n-2<\/sub><\/p>\n<p>  \u0438 F<sub>1<\/sub>= F<sub>2<\/sub>=1.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-260124","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/260124","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=260124"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/260124\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=260124"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=260124"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=260124"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}