Prime Factors

From codewars.com by Edxael  (that’s me)

Description:

Inspired by one of Uncle Bob’s TDD Kata

Write a function that generates factors for a given number.

  • The function takes an integer on the standard input and returns a list of integers. That list contains the prime factors in numerical sequence.

Example

  • 1 -> []
  • 3 -> [3]
  • 8 -> [2, 2, 2]
  • 9 -> [3, 3]
  • 12 -> [2, 2, 3]

: – – My Code – – :

Note:  The following code is not written by me, it was created by another user of codewars.com it belongs to the user: njohnson7

 

x



Copyright 2017. All rights reserved.

Posted January 17, 2017 by Edmundo in category "Ruby Examples