Hackerearth august circuit question no.1

my code is giving wrong answer please help me out.
I have done all the things right.

Try this

1 Like

Its basically converting the number to base 3 but make sure to handle large numbers, maybe doing in Python helps