The Challenge

Given a number, find the sum of the non-composite numbers in the Fibonacci sequence up to that number, and find the prime factors of the sum.

For example, if you were given 8, the non-composite numbers would be 1, 1, 2, 3, and 5. Adding these up would get 12. The prime factors of 12 are 2, 2 and 3, so your program should return something along the lines of 2, 2, 3 when given 12.

The Objective

This is Code Golf, so the answer with the least amount of bytes wins.

  • 5
    \$\begingroup\$ The title reads like something out of a PPCG Markov chain generator. Primes and Fibonacci numbers have been way overdone (see this about primes). This isn't something I'd expect a new user to necessarily know, so a heads up for potential downvotes. \$\endgroup\$ – xnor Feb 20 '18 at 7:04

Neim, 8 bytes


Doesn't work on TIO, but works locally.


𝐈            Inclusive range [1 .. input]
 f           Fibonacci numbers
  𝕌         Get elements that are only in both lists
   Σ         Keep each element where running the following is falsy
    𝐭          Check if composite
     }       Close loop
      𝐬       Sum
       𝐏     Prime factors

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.