variable to represent the number after converting it to base 5. Since the digits are be in reverse order , we traverse vector from back
$ result = 0 ; for ( $ i = count ( $ v ) - 1 ; $ i >= 0 ; $ i -- ) { $ result = $ result * 10 ; $ result = $ result + $ v [ $ i ] ; }