Here is a FORTRAN 90 answer (the module and an example program):

MODULEdecomposeIMPLICITNONECONTAINSSUBROUTINEdecomp(n,primes,powers,factorial)INTEGER,INTENT(IN)::nINTEGER,ALLOCATABLE,INTENT(OUT)::primes(:),powers(:)INTEGER,INTENT(OUT)::factorialINTEGER::i,j,m,currentINTEGER,DIMENSION(25)::lowPrimesDATAlowPrimes/2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97/IF(n.GT.100)THEN!can't handle a too big numberPRINT*,"Choose a number less than 100"RETURNENDIFm=COUNT(lowPrimes.LE.n)!how many integers less or equal to n!initial valuesALLOCATE(primes(m),powers(m))primes=lowPrimes(1:m)powers=0factorial=1!decomposing n! number by numberDOi=2,nfactorial=factorial*icurrent=iDOj=1,mIF(MOD(current,primes(j)).EQ.0)THENcurrent=INT(current/primes(j))powers(j)=powers(j)+1ENDIFIF(current.EQ.1)EXIT! we are done decomposing iENDDO!jENDDO!iENDSUBROUTINEdecompENDMODULEdecomposePROGRAMtestDecomposeUSEdecomposeIMPLICITNONEINTEGER::myInt,m,iINTEGER,ALLOCATABLE::pr(:),po(:)INTEGER::famyInt=12CALLdecomp(n=myInt,primes=pr,powers=po,factorial=fa)!printing the result:WRITE(*,"(i3,a4,i12,a3)",advance='no')myInt,"! = ",fa," = "m=SIZE(pr)DOi=1,mIF(po(i).GT.0)WRITE(*,"(i2,a1,i2)",advance='no')pr(i),"^",po(i)IF(i.LT.m)WRITE(*,"(a3)",advance='no')" + "ENDDOPRINT*," "ENDPROGRAMtestDecompose

Here is a FORTRAN 90 answer (the module and an example program):

The result looks like:

12! = 479001600 = 2^ 6 + 3^ 4 + 5^ 2 + 7^ 1 + 11^ 1

Note: I hard coded n=12 but I could made n be read from the command line