{"id":156,"date":"2019-01-21T22:39:44","date_gmt":"2019-01-22T03:39:44","guid":{"rendered":"https:\/\/resrvoir.com\/?page_id=156"},"modified":"2025-06-17T22:47:03","modified_gmt":"2025-06-18T02:47:03","slug":"reverse-an-integer","status":"publish","type":"page","link":"https:\/\/resrvoir.com\/?page_id=156","title":{"rendered":"Reverse an Integer (easy)"},"content":{"rendered":"\r\n<p>Reverse an integer using math operations.<br \/><br \/>Build up a new number m by multiplying by 10 and dividing the original number n by 10 until n is 0. The digit in the &#8216;ones&#8217; position is taken from the original and added to the new number at each iteration.<\/p>\r\n\r\n\r\n\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">int reverse(int n) {\r\n  int m = 0\r\n\r\n  while (n) {\r\n    int r = n % 10\r\n    m = m * 10 + r\r\n    n = n \/ 10\r\n  }\r\n\r\n  return m\r\n}<\/pre>\r\n","protected":false},"excerpt":{"rendered":"<p>Reverse an integer using math operations. Build up a new number m by multiplying by 10 and dividing the original number n by 10 until n is 0. The digit in the &#8216;ones&#8217; position is taken from the original and added to the new number at each iteration.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":2,"menu_order":5,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"_links":{"self":[{"href":"https:\/\/resrvoir.com\/index.php?rest_route=\/wp\/v2\/pages\/156"}],"collection":[{"href":"https:\/\/resrvoir.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/resrvoir.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/resrvoir.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/resrvoir.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=156"}],"version-history":[{"count":6,"href":"https:\/\/resrvoir.com\/index.php?rest_route=\/wp\/v2\/pages\/156\/revisions"}],"predecessor-version":[{"id":1411,"href":"https:\/\/resrvoir.com\/index.php?rest_route=\/wp\/v2\/pages\/156\/revisions\/1411"}],"up":[{"embeddable":true,"href":"https:\/\/resrvoir.com\/index.php?rest_route=\/wp\/v2\/pages\/2"}],"wp:attachment":[{"href":"https:\/\/resrvoir.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}