Most Wondrous
Below is the length of the wondrous sequence I get when starting with certain numbers. For example, the sequence starting with 97 has length 119.
Write a C program to find the smallest starting value which has length over 1234.
tip: be careful of your numbers getting too big and overflowing. You might want to investigate unsigned long long numbers, and/or think of your own way of representing big numbers using two or more smaller numbers somehow.
Don’t use any c libraries except those we have already covered in class.
- 1 has length 1
- 2 has length 2
- 3 has length 8
- 6 has length 9
- 7 has length 17
- 9 has length 20
- 18 has length 21
- 25 has length 24
- 27 has length 112
- 54 has length 113
- 73 has length 116
- 97 has length 119
- 129 has length 122
- 171 has length 125
- 231 has length 128
- 313 has length 131
- 327 has length 144
- 649 has length 145
- 703 has length 171
- 871 has length 179
- 1161 has length 182
- 2223 has length 183
- 2463 has length 209
- 2919 has length 217
- 3711 has length 238
- 6171 has length 262
- 10971 has length 268
- 13255 has length 276
- 17647 has length 279
- 23529 has length 282
- 26623 has length 308
- 34239 has length 311
- 35655 has length 324
- 52527 has length 340
- 77031 has length 351
- 106239 has length 354
- 142587 has length 375
- 156159 has length 383
- 216367 has length 386
- 230631 has length 443
- 410011 has length 449
- 511935 has length 470
- 626331 has length 509
- 837799 has length 525
- 1117065 has length 528
- 1501353 has length 531
- 1723519 has length 557
- 2298025 has length 560
- 3064033 has length 563
- 3542887 has length 584
- 3732423 has length 597
- 5649499 has length 613
- 6649279 has length 665
- 8400511 has length 686
- 11200681 has length 689
- 14934241 has length 692
- 15733191 has length 705
- 31466382 has length 706
- 36791535 has length 745
- 63728127 has length 950
- 127456254 has length 951
- 169941673 has length 954
- 226588897 has length 957
- 268549803 has length 965
- 537099606 has length 966
- 670617279 has length 987
- 1341234558 has length 988
Save your answer in a text file called mostwondrous.txt
, and submit
that when you have found the answer.
To run Styl-o-matic:
$ 1511 stylomatic mostwondrous.txt Looks good!
You’ll get advice if you need to make changes to your code.
Submit your work with the give command, like so:
$ give cs1511 wk07_mostWondrous
Or, if you are working from home, upload the relevant file(s) to the wk07_mostWondrous activity on Give Online.