Got to write a program that factors a given number(>1)(adsbygoogle = window.adsbygoogle || []).push({});

Here is what I have:

program Factors

implicit none

real::n, i

print*, "enter a number:"

read*, n

i=2

do while (n>1)

if (mod(n, i)==0) then

i=i+1

n=n/i

else

write (*,*) ' X= ', X

end if

end do

end program

It works great but lets say you put in 600, it will give

2

2

2

3

5

5

which is right but the teacher wants it to say:

2**3*3*5**2

I dont have a clue how to make it do that.

Thanks for any help. :)

**Physics Forums - The Fusion of Science and Community**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Factoring in Fortran

Loading...

Similar Threads for Factoring Fortran | Date |
---|---|

If statement for Monte Carlo integration | Apr 15, 2018 |

Project Euler solution 3 | Aug 30, 2017 |

Ruby recursive factorization | Jan 8, 2017 |

Fermat Factoring (Zeda's Method) | Dec 26, 2013 |

Load factor and rehashing in hashsets | Oct 31, 2012 |

**Physics Forums - The Fusion of Science and Community**