TASK #1 - Two Friendly You are given 2 positive numbers, $m and $n. Write a script to find out if the given two numbers are Two Friendly. Two positive numbers, m and n are two friendly when gcd(m, n) = 2 ^ p where p > 0. The greatest common divisor (gcd) of a set of numbers is the largest positive number that divides all the numbers in the set without remainder. Example 1 Input: $m = 8, $n = 24 Output: 1 Reason: gcd(8,24) = 8 => 2 ^ 3 Example 2 Input: $m = 26, $n = 39 Output: 0 Reason: gcd(26,39) = 13 Example 3 Input: $m = 4, $n = 10 Output: 1 Reason: gcd(4,10) = 2 => 2 ^ 1 MY NOTES: Pretty easy. Euclid's GCD algorithm, then check if the result is a power of 2. TASK #2 - Fibonacci Sequence You are given a positive number $n. Write a script to find how many different sequences you can create using Fibonacci numbers where the sum of unique numbers in each sequence are the same as the given number. Fibonacci Numbers: 1,2,3,5,8,13,21,34,55,89,.. Example 1 Input: $n = 16 Output: 4 Reason: There are 4 possible sequences that can be created using Fibonacci numbers i.e. (3 + 13), (1 + 2 + 13), (3 + 5 + 8) and (1 + 2 + 5 + 8). Example 2 Input: $n = 9 Output: 2 Reason: There are 2 possible sequences that can be created using Fibonacci numbers i.e. (1 + 3 + 5) and (1 + 8). Example 3 Input: $n = 15 Output: 2 Reason: There are 2 possible sequences that can be created using Fibonacci numbers i.e. (2 + 5 + 8) and (2 + 13). MY NOTES: Pretty easy - find subsets of the first few Fibonacci numbers that sum to N. How many Fibonacci numbers should we consider? Those <= N. Then, how do we sum subsets of them? Two obvious ways: 1. recursive function, iterating over the Fibonacci values: each value is either in the subset or not, try both possibilities. 2. binary-counting method, iterate over every combination C from 1 .. 2**(number values)-1, then sum up only the elements where the corresponding bit in C is true.