fixed recursive digit counter