diff --git a/fortran/src/p0004.f90 b/fortran/src/p0004.f90 index 06bd8e93..514c16be 100644 --- a/fortran/src/p0004.f90 +++ b/fortran/src/p0004.f90 @@ -9,7 +9,7 @@ module Problem0004 implicit none contains integer function p0004() result(answer) - integer :: i, j, k, prod, length + integer :: i, j, k, n, prod, length logical :: is_palindrome character(len=8) :: string @@ -21,7 +21,8 @@ integer function p0004() result(answer) length = len(string) do k = 1, length - if (string(k) /= string(length - k + 1)) then + n = length - k + 1 + if (string(k:k) /= string(n:n)) then is_palindrome = .false. exit end if