Note 1: The script uses a lazy evaluation of logic operators -or and -and. If "$args"-notmatch'(.)(.*)(.)' is True then the right subexpression of -or is not evaluated. Also if ($m=$Matches).1-ge$m.3 is False then the right subexpression of -and is not evaluated too. So we avoid infinite recursion.
Note 2: The regular expression '(.)(.*)(.)' does not contain start and end anchors because the expression (.*) is greedy by default.
$g={ "$args"-notmatch'(.)(.*)(.)'-or(($m=$Matches).1-ge$m.3-and(&$g(''+(+$m.1+$m.3)%10+$m.2))) } @( ,(2632, $true) ,(92258, $true) ,(60282, $true) ,(38410, $true) ,(3210, $true) ,(2302, $true) ,(2742, $true) ,(8628, $true) ,(6793, $true) ,(1, $true) ,(2, $true) ,(10, $true) ,(100, $true) ,(55, $true) ,(121, $true) ,(6724, $false) ,(47, $false) ,(472, $false) ,(60247, $false) ,(33265, $false) ,(79350, $false) ,(83147, $false) ,(93101, $false) ,(57088, $false) ,(69513, $false) ,(62738, $false) ,(54754, $false) ,(23931, $false) ,(7164, $false) ,(5289, $false) ,(3435, $false) ,(3949, $false) ,(8630, $false) ,(5018, $false) ,(6715, $false) ,(340, $false) ,(2194, $false) ) | %{ $n,$expected = $_ #$result = .\g $n # uncomment this line to call a separate script file g.ps1 $result = &$g $n # commentuncomment this line to call a separate script fileblock variable $g # the script block call and the script file call has same bytes "$($result-eq-$expected): $result <- $n" }