# 6. Functions, recursion and tail recursion in Scala homework ## Что нужно сделать ### Fork a repo * Отправьте мне свой GitHub профайл, чтобы я дал Вам доступ к репозиторию. * Сделайте fork репозитория [этого](https://github.com/KarazinScalaUsersGroup/scala-course-2020) репозитория. * Убедитесь, что Ваш fork приватный. * Добавьте меня в Ваш fork. [Как сделать fork репозитория](https://docs.github.com/en/free-pro-team@latest/github/getting-started-with-github/fork-a-repo) ### Тема домашней работы Внимательно просмотрите код. * Основной код * https://github.com/KarazinScalaUsersGroup/scala-course-2020/blob/master/src/main/scala/karazin/scala/users/group/recursion/Topic.scala * Тесты * https://github.com/KarazinScalaUsersGroup/scala-course-2020/blob/master/src/test/scala/karazin/scala/users/group/recursion/TopicSpecification.scala * https://github.com/KarazinScalaUsersGroup/scala-course-2020/blob/master/src/test/scala/karazin/scala/users/group/recursion/arbitraries.scala * https://github.com/KarazinScalaUsersGroup/scala-course-2020/blob/master/src/test/scala/karazin/scala/users/group/recursion/utils.scala ## Задания ### Preface Implement all the things with `@Hack` annotation. All implementations must be tail-recursive is possible. Feel free to use internal methods/functions. Feel free to adjust signatures of hacked methods/functions. *All tests should pass.* I have additional test for the functionality. My tests also *should pass*. Feel free to add more test cases. ### How to pass Create a new branch `homework-6`. You *should not* commit your solution to your `*master*` branch, only to `homework-6` branch. You can do as many commits as you want to `homework-6`. Please provide any commit wiht meaningful commit message following the format ``` HOMEWORK-6 - <brief explanation> <detailed explanation if neede> ``` Yes, `HOMEWORK-6` is in upper case. Yes, `HOMEWORK-6` then ` ` (**space**) then `-` (**dash**) then ` ` (**space**) then brief explanation. After the implementation (with tests) is done create *merge request* (aka code review aka pr) and add me as a reviewer... and the battle begins! ### Code templates The implementation should be done here: * https://github.com/KarazinScalaUsersGroup/scala-course-2020/blob/master/src/main/scala/karazin/scala/users/group/recursion/homework/Homework.scala * https://github.com/KarazinScalaUsersGroup/scala-course-2020/blob/master/src/test/scala/karazin/scala/users/group/recursion/homework/HomeworkSpecification.scala * https://github.com/KarazinScalaUsersGroup/scala-course-2020/blob/master/src/test/scala/karazin/scala/users/group/recursion/homework/arbitraries.scala ### 1. Boolean Operators *Required task* Implement eager boolean operations Not, And and Or. Requirements: * the function should not use embedded boolean operations * the functions should be eager * the function should use `if` expression and `true` and `false` boolean literals ### 2. Fermat Numbers *Required task* Implemet function which should calculate n-th Fermath number: `Fn = 2 ^ (2 ^ n) + 1`, n is non-negative Requirements: * the function should not use multiplication and power operations * the functions should only use addition operattion * For more details [see](https://en.wikipedia.org/wiki/Fermat_number). ### 3. Look-and-say Sequence *Required task* Implement function which should calculate n-th number of Look-and-say sequence For more details [see](https://en.wikipedia.org/wiki/Look-and-say_sequence). ### 4. Kolakoski sequence *Optional super challenging task (I have no idea how to implement it)* Implement function which should calculate n-th number of Kolakoski sequence For more details [see](https://en.wikipedia.org/wiki/Kolakoski_sequence). ## Проблемы с подсветкой синтаксиса для Dotty Проверьте настройки проекта: ![](https://i.imgur.com/Li71dFd.png) ![](https://i.imgur.com/3Aeic62.png) ## Ограничение доступа к форку Удалите группу `scala-course-2020` из форка, как это показано здесь: ![](https://i.imgur.com/vlQRWD8.png)