PROGRAM Onion_Layers IMPLICIT NONE INTEGER :: n, layer, i, size_seed PRINT*, "Type in a seed for the Random Number Jenny" READ*, n CALL RANDOM_SEED(SIZE=size_seed) CALL RANDOM_SEED(PUT=(/(n, i = 1,size_seed)/)) layer = depth() IF(layer .GT. 0)THEN WRITE(*,*) ' Bug found at depth ', layer ELSE WRITE(*,*) ' Bug not found' ENDIF CONTAINS RECURSIVE FUNCTION depth() RESULT(layer) INTEGER :: layer REAL :: harvest INTEGER :: count = 0 count = count + 1 CALL RANDOM_NUMBER(harvest) WRITE(*,*) 'Random number = ' ,harvest IF(harvest .LT. .1)THEN layer = count RETURN ELSE layer = depth() ENDIF END FUNCTION depth END Program