Syntax error when using “X != 0” in Fortran

前端 未结 3 1436
无人共我
无人共我 2021-01-19 00:59

I have a problem with my Fortran program that does nothing more than calculating a prime factorization (or should do). That\'s the error:

C:\\MinGW\\Fortran>         


        
3条回答
  •  无人及你
    2021-01-19 01:46

    You're using the wrong notation for 'not equal to'. Fortran syntax is /= or .NE..

    So you should be using:

    if (prim(i) /= 0 .and. modulo(n, prim(i)) == 0) then
    

    and

    if (prim(i) /= 0) then
    

    Furthermore, your syntax of integer(sqrt(real(m))) is incorrect, perhaps you mean NINT(sqrt(real(m)))?

提交回复
热议问题