chicken666
Programmer
Can anybody tell me why i can't get correct result from non recursive function called inside recursive function
Here is an example
integer function test()
integer test
test = 69
return
end function test
integer recursive function testRec(i)
integer, intent(inout) :: i
integer :: testRec
print *, i
print *, test()
if(i <= 0) then
return
end if
i = i-1
testRec = testRec(i)
return
end function testRec
and the result
3
NaN
2
NaN
1
NaN
0
NaN
Why does function test return Nan instead of 69??
Here is an example
integer function test()
integer test
test = 69
return
end function test
integer recursive function testRec(i)
integer, intent(inout) :: i
integer :: testRec
print *, i
print *, test()
if(i <= 0) then
return
end if
i = i-1
testRec = testRec(i)
return
end function testRec
and the result
3
NaN
2
NaN
1
NaN
0
NaN
Why does function test return Nan instead of 69??