Created
February 6, 2018 21:36
-
-
Save AnthonyMikh/fde39617ebc6d02dfac2df42cb001d12 to your computer and use it in GitHub Desktop.
Обоснование решения задачи №68 от UniLecs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Seq = String | |
type Solution = [Seq] | |
seed :: Solution | |
seed = ["44", "47", "74", "77"] | |
extendSeq :: Seq -> [Seq] | |
extendSeq base@(x:y:ys) = | |
case (x, y) of | |
('4', '4') -> ['7':base] | |
('7', '7') -> ['4':base] | |
(_, _) -> ['4':base, '7':base] | |
extendSolution :: Solution -> Solution | |
extendSolution = concatMap extendSeq | |
solutionsList :: [Solution] | |
solutionsList = iterate extendSolution seed | |
showSolution :: Solution -> String | |
showSolution = unwords | |
showSolutions :: [Solution] -> String | |
showSolutions = unlines . map showSolution | |
fibs = 0 : 1 : zipWith (+) fibs (tail fibs) | |
fibs2 = map (*2) fibs | |
main = putStr . unlines . take 12 . map show . zip (drop 3 fibs2) . map length $ solutionsList |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Вывод:
Таким образом, как минимум первые члены ряда описываются формулой
A(n) = 2*F(n+1)
, гдеF(n)
-n
-ый член ряда Фибоначчи