#Pip, 41 bytes
Pip, 41 bytes
Not a competing answer, since language is newer than question. But that GolfScript mark of 68 needed to come down.
Fi2,++a{p:0T$|g%i{++pg/:i}Ipx.:i.'^.p.s}x
Output ends in a space; if that's a problem, the following version is also 41 bytes (including the -s
flag):
Fi2,++a{p:0T$|g%i{++pg/:i}IplAE:i.'^.p}l
Formatted, with explanations:
F i 2,++a { For i in range(2,a+1); note ++ used to avoid parentheses in 2,(a+1)
p:0 p will store the greatest power of i that divides both numbers
T $+(g%i) { Loop till the sum of g%i is nonzero, where g is a list initialized
from cmdline args
++p As long as g%i is [0 0], increment p...
g/:i ...and divide both numbers in g by i
}
I p If p is nonzero, i went into both numbers at least once
x.:i.'^.p.s Append i^p and a space to the result
}
x Print the result
Pip, unlike GolfScript, CJam, et al. is an imperative language with infix operators; it also takes some inspiration from array-programming languages. This task nicely displays both paradigms at work.
(Note that the 2015-4-20 commit is needed to run this, since I just fixed a couple of bugs.)