Cody

# Problem 45663. Find the next binary palindrome number

Solution 2410651

Submitted on 29 May 2020 by Binbin Qi
• Size: 22
• This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
x = 241; y_correct = 255; assert(isequal(NextBinaryPalindrome(x),y_correct))

x = 242 x = 243 x = 244 x = 245 x = 246 x = 247 x = 248 x = 249 x = 250 x = 251 x = 252 x = 253 x = 254 x = 255

2   Pass
x = 2020; y_correct = 2047; assert(isequal(NextBinaryPalindrome(x),y_correct))

x = 2021 x = 2022 x = 2023 x = 2024 x = 2025 x = 2026 x = 2027 x = 2028 x = 2029 x = 2030 x = 2031 x = 2032 x = 2033 x = 2034 x = 2035 x = 2036 x = 2037 x = 2038 x = 2039 x = 2040 x = 2041 x = 2042 x = 2043 x = 2044 x = 2045 x = 2046 x = 2047

3   Pass
x = 10051; y_correct =10233; assert(isequal(NextBinaryPalindrome(x),y_correct))

x = 10052 x = 10053 x = 10054 x = 10055 x = 10056 x = 10057 x = 10058 x = 10059 x = 10060 x = 10061 x = 10062 x = 10063 x = 10064 x = 10065 x = 10066 x = 10067 x = 10068 x = 10069 x = 10070 x = 10071 x = 10072 x = 10073 x = 10074 x = 10075 x = 10076 x = 10077 x = 10078 x = 10079 x = 10080 x = 10081 x = 10082 x = 10083 x = 10084 x = 10085 x = 10086 x = 10087 x = 10088 x = 10089 x = 10090 x = 10091 x = 10092 x = 10093 x = 10094 x = 10095 x = 10096 x = 10097 x = 10098 x = 10099 x = 10100 x = 10101 x = 10102 x = 10103 x = 10104 x = 10105 x = 10106 x = 10107 x = 10108 x = 10109 x = 10110 x = 10111 x = 10112 x = 10113 x = 10114 x = 10115 x = 10116 x = 10117 x = 10118 x = 10119 x = 10120 x = 10121 x = 10122 x = 10123 x = 10124 x = 10125 x = 10126 x = 10127 x = 10128 x = 10129 x = 10130 x = 10131 x = 10132 x = 10133 x = 10134 x = 10135 x = 10136 x = 10137 x = 10138 x = 10139 x = 10140 x = 10141 x = 10142 x = 10143 x = 10144 x = 10145 x = 10146 x = 10147 x = 10148 x = 10149 x = 10150 x = 10151 x = 10152 x = 10153 x = 10154 x = 10155 x = 10156 x = 10157 x = 10158 x = 10159 x = 10160 x = 10161 x = 10162 x = 10163 x = 10164 x = 10165 x = 10166 x = 10167 x = 10168 x = 10169 x = 10170 x = 10171 x = 10172 x = 10173 x = 10174 x = 10175 x = 10176 x = 10177 x = 10178 x = 10179 x = 10180 x = 10181 x = 10182 x = 10183 x = 10184 x = 10185 x = 10186 x = 10187 x = 10188 x = 10189 x = 10190 x = 10191 x = 10192 x = 10193 x = 10194 x = 10195 x = 10196 x = 10197 x = 10198 x = 10199 x = 10200 x = 10201 x = 10202 x = 10203 x = 10204 x = 10205 x = 10206 x = 10207 x = 10208 x = 10209 x = 10210 x = 10211 x = 10212 x = 10213 x = 10214 x = 10215 x = 10216 x = 10217 x = 10218 x = 10219 x = 10220 x = 10221 x = 10222 x = 10223 x = 10224 x = 10225 x = 10226 x = 10227 x = 10228 x = 10229 x = 10230 x = 10231 x = 10232 x = 10233

4   Pass
x =40504; y_correct =40569; assert(isequal(NextBinaryPalindrome(x),y_correct))

x = 40505 x = 40506 x = 40507 x = 40508 x = 40509 x = 40510 x = 40511 x = 40512 x = 40513 x = 40514 x = 40515 x = 40516 x = 40517 x = 40518 x = 40519 x = 40520 x = 40521 x = 40522 x = 40523 x = 40524 x = 40525 x = 40526 x = 40527 x = 40528 x = 40529 x = 40530 x = 40531 x = 40532 x = 40533 x = 40534 x = 40535 x = 40536 x = 40537 x = 40538 x = 40539 x = 40540 x = 40541 x = 40542 x = 40543 x = 40544 x = 40545 x = 40546 x = 40547 x = 40548 x = 40549 x = 40550 x = 40551 x = 40552 x = 40553 x = 40554 x = 40555 x = 40556 x = 40557 x = 40558 x = 40559 x = 40560 x = 40561 x = 40562 x = 40563 x = 40564 x = 40565 x = 40566 x = 40567 x = 40568 x = 40569

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!