For clear definition, as $_ value got changed in every recursive call of R() function, $1 value also got changed and in return of every recursive call, the last changed value available and that is the reason for getting '1' 5 times in $1.
For better understanding, here below I have shown how that recursive calls and values of $_ and $1 will be.
Initial ( First ) callback of R() function:
$_='x55x666x7777x1x'; $_=undefined;
Inside code, after evaluating s/(\d+)// ? $1 + R() : 0;
$1=55; #immediately after executing s// command
Second callback of R():
$_='xx666x7777x1x'; $1=55;
Inside code, after evaluating s/(\d+)// ? $1 + R() : 0;
$1=666; #immediately after executing s// command
Third callback of R():
$_='xxx7777x1x'; $1=666;
Inside code, after evaluating s/(\d+)// ? $1 + R() : 0;
$1=7777; #immediately after executing s// command
Fourth callback of R():
$_='xxxx1x'; $1=7777;
Inside code, after evaluating s/(\d+)// ? $1 + R() : 0;
$1=1; #immediately after executing s// command
Fifth callback of R():
$_='xxxxx'; $1=1;
Inside code, after evaluating s/(\d+)// ? $1 + R() : 0;
# no callback executed as ( there are no digits ) pattern not matched
$1=undefined; #immediately after executing s// command
# after prints 'xxxxx' and '1' for fifth callback
# after prints 'xxxxx' and '1' for fourth callback
# after prints 'xxxxx' and '1' for third callback
# after prints 'xxxxx' and '1' for second callback
# after prints 'xxxxx' and '1' for first callback
Kindly regret me for format. I unable to get exact stack of recursive calls for presentation.