{"id":1174,"date":"2019-10-25T14:10:37","date_gmt":"2019-10-25T14:10:37","guid":{"rendered":"https:\/\/muthu.co\/?p=1174"},"modified":"2021-05-24T02:40:18","modified_gmt":"2021-05-24T02:40:18","slug":"function-to-get-the-preceding-odd-number-y-for-any-given-number-x","status":"publish","type":"post","link":"http:\/\/write.muthu.co\/function-to-get-the-preceding-odd-number-y-for-any-given-number-x\/","title":{"rendered":"Function to get the preceding odd number (y) for any given number (x)"},"content":{"rendered":"\n

For any function,<\/p>\n\n\n\n

\"\"<\/a><\/figure><\/div>\n\n\n\n

We want, for every value of x, return the corresponding odd number. If x is odd then return it as it is, else return the next number. This can easily be done using a computer program by checking if the number is odd or even. But if you had to find a general formula we would need the help of some basic maths.<\/p>\n\n\n\n

Let’s decompose our above function and see what we can extract.<\/p>\n\n\n\n

\"\"<\/a><\/figure><\/div>\n\n\n\n

We just need to find a general formula for the second digit on the RHS which is alternating between 0 and 1. Our function now looks like:<\/p>\n\n\n\n

\"\"<\/a><\/figure><\/div>\n\n\n\n

The series 0,1,0,1.. can be easily represented by the below formula:<\/p>\n\n\n\n

\"\"<\/a><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"

For any function, We want, for every value of x, return the corresponding odd number. If x is odd then return it as it is, else return the next number. This can easily be done using a computer program by checking if the number is odd or even. But if you had to find a […]<\/p>\n","protected":false},"author":1,"featured_media":1182,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[54],"_links":{"self":[{"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/posts\/1174"}],"collection":[{"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/comments?post=1174"}],"version-history":[{"count":3,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/posts\/1174\/revisions"}],"predecessor-version":[{"id":1857,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/posts\/1174\/revisions\/1857"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/media\/1182"}],"wp:attachment":[{"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/media?parent=1174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/categories?post=1174"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/tags?post=1174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}