Find prime factors of sum of non-composite Fibonacci numbers up to n

-4

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.

rappatic

Posted 2018-02-20T06:37:41.780

Reputation: 103

5

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.

– xnor – 2018-02-20T07:04:33.590

Answers

2

Neim, 8 bytes

fΣ}

Doesn't work on TIO, but works locally.

Explanation:

            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

Okx

Posted 2018-02-20T06:37:41.780

Reputation: 15 025