CJam, 26 bytes
qi_[XY@{_2$+}*]_@\f%:!.*:+
I'm sure it can be done better. WritingExplanation:
The idea is to have an array of Fibonacci numbers and dot product it with an array with 1s and 0s if that number is or is not a divisor of the explanation..input.
qi Read the input (n)
[XY ] Array starting with [1,2,...]
_ @{_2$+}* Append n times the sum of the previous two
_ Duplicate the array
@\f% Modulo each item with n (0 if divisor, a number otherwise)
:! Logical NOT everything (1 if divisor, 0 otherwise)
.*:+ Dot product those two arrays
CJam, 26 bytes
qi_[XY@{_2$+}*]_@\f%:!.*:+
I'm sure it can be done better. Writing the explanation...
CJam, 26 bytes
qi_[XY@{_2$+}*]_@\f%:!.*:+
I'm sure it can be done better. Explanation:
The idea is to have an array of Fibonacci numbers and dot product it with an array with 1s and 0s if that number is or is not a divisor of the input.
qi Read the input (n)
[XY ] Array starting with [1,2,...]
_ @{_2$+}* Append n times the sum of the previous two
_ Duplicate the array
@\f% Modulo each item with n (0 if divisor, a number otherwise)
:! Logical NOT everything (1 if divisor, 0 otherwise)
.*:+ Dot product those two arrays