VBA, (削除) 209 (削除ここまで) (削除) 147 (削除ここまで) 142 bytes
Sub p(k)
For i=1To k
a=StrReverse(q)
If Left(Replace(a,"0",""),1)=2Then:q=q-2*10^(InStr(a,2)-1)+10^InStr(a,2):Else:q=q+1
Next
msgbox q
End Sub
My math is inefficient and my golfing could use work. But it's my first attempt at PoG and thought I'd give this one a try. Sort of a Brute Force way though.
It's just counting by 1 unless the last digit is a 2 then steps back by 2 and jumps forward 10. Plus the trailing 0's.
This stops working at 65534 because VBA insists on giving output in scientific notation, but the logic should work fine for even higher numbers
Looking forward to golfing suggestions, VBA is not very golf-friendly but it's not often represented, and I think it can beat Java for length.
Edit1: Thanks Manu for helping shave off 62 bytes
Edit2: Swapped debug.print for msgbox as output. Saved 5 bytes
- 691
- 4
- 9