19 lines
450 B
Text
19 lines
450 B
Text
WRITE(Messagebox) NthRoot(5, 34)
|
|
WRITE(Messagebox) NthRoot(10, 7131.5^10)
|
|
|
|
FUNCTION NthRoot(n, A)
|
|
REAL :: prec = 0.001
|
|
|
|
IF( (n > 0) * (A > 0) ) THEN
|
|
NthRoot = A / n
|
|
DO i = 1, 1/prec
|
|
x = ((n-1)*NthRoot + A/(NthRoot^(n-1))) / n
|
|
IF( ABS(x - NthRoot) <= prec ) THEN
|
|
RETURN
|
|
ENDIF
|
|
NthRoot = x
|
|
ENDDO
|
|
ENDIF
|
|
|
|
WRITE(Messagebox, Name) 'Cannot solve problem for:', prec, n, A
|
|
END
|