fork download
  1. program PowersOfOne
  2. ! This program calculates the powers of 1 by using the equivalence i^4=1
  3. ! where i is the imaginary unit and z is the complex exponent such that
  4. ! 1^z=n.
  5. implicit none
  6. complex, parameter :: I = (0, 1)
  7. real :: n, PI
  8. complex :: z
  9. read *, n
  10. z = log(n) / (4 * log(I))
  11. print *, z
  12. PI = atan(1.0)
  13. print *, exp(2 * PI * I * (4.0 * z))
  14. end program PowersOfOne
Success #stdin #stdout 0.01s 5288KB
stdin
15
stdout
          (0.000000000,-0.430999577)
            (15.0000010,0.000000000)