# Prime Factor Random Numbers! [duplicate]

Given two positive integers, generate a random integer between them (inclusive) and then output all its prime factors.

### Examples:

Input:   Random Number:     Output:
1,2      2                  [2]
12,46    18                 [2,9]
142,17   40                 [2,2,2,5]


### Scoring:

This is so the least bytes wins!

# 05AB1E, 4 bytes

Ÿ.RÒ


Explanation:

Ÿ       Create a list [a .. b]
.R     Pick a random element
Ò    Prime factors.


Try it online!

# Jelly, 5 4 bytes

rXÆf


Try it online!

How it works

rXÆf
r     inclusive range
X    random element's
Æf  prime factorization


-1 byte thanks to @LeakyNun

• 4 bytes: rXÆf Jun 10, 2017 at 15:42
• Thanks. I thought there would be a problem with range using the first argument and the output of X applied to the second argument. Jun 10, 2017 at 15:44
• The 21 rule only applies in monadic chains. Jun 10, 2017 at 15:50

## Mathematica, 38 bytes

#&@@@FactorInteger@RandomInteger@{##}&


# Pyth, 4 bytes

PO}F


Test suite.

for($a=rand($argv[1],$argv[$i=2]);1<$a;)$a%$i?$i++:$a/=$i+!$r[]=$i;print_r($r);  Try it online! # Pyffman 1, 90 80 bytes This is a joke language that was published today (but before the challenge!). It is based on compressing Python using a pre-made Huffman code based on a corpus of golfed Python. Since the code doesn't really consist of bytes (it's bit-based, due to its huffmannness), I give you here the hexdump obtained using xxd. 00000000: 9c23 9c8f f5fe 9e1d 744a 4ac4 860f 2fcb .#......tJJ.../. 00000010: 1218 3cbf 70d5 9577 b8cb 4059 44a4 2dbf ..<[email protected]. 00000020: fbaa 9763 4a75 bbbb 90e1 7ac8 410f fbba ...cJu....z.A... 00000030: 0c91 a0d8 528d dde3 8fd9 0e19 0c56 2ca6 ....R........V,. 00000040: c699 893b 9e1b bc47 fb29 b1a6 624e 79e8 ...;...G.)..bNy.  (The original Python code this is based on is 164 158 bytes.) # CJam, 13 bytes {$~),\,-mRmf}


Anonymous block that expects an array of two numbers in the stack and replaces it by an array with the output.

Try it online!

### Explanation

{       e# Begin block
\$     e# Sort array
~     e# Split into the two numbers, a and b, where b is greater
)     e# Increment b
,     e# Range from 0 to b
\     e# Swap
,     e# Range from 0 to a-1
-     e# Set difference: range from a to b
mR    e# Random choice
mf    e# Array of prime factors
}       e# End block


# Japt, 7 6 bytes

óV ö k


Try it online!

Explanation

oVÄ ö k
oVÄ        range of integers between first input and second input + 1
ö      get a random item from the array
k    return all prime factors


Saved a byte thanks to ETHproductions

# MATL, 5 bytes

SYrYf


Try it at MATL Online

Explanation

        % Implicitly grab input as a 1 x 2 array
S       % Sort the input such that the lower end of the range comes first
Yr      % Generate a random integer in this range
Yf      % Compute it's prime factors
% Implicitly display the result