Cody

# Problem 166. Kaprekar numbers

Solution 1996869

Submitted on 30 Oct 2019 by Asif Newaz
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 = 16; tf_correct = false; assert(isequal(kap(x),tf_correct))

a = 256 b = '256' m = 3 c = 58

2   Pass
x = 704; tf_correct = false; assert(isequal(kap(x),tf_correct))

a = 495616 b = '495616' m = 6 c = 1111

3   Pass
x = 9 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 9 tf_correct = logical 1 a = 81 b = '81' m = 2 c = 9

4   Pass
x = 45 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 45 tf_correct = logical 1 a = 2025 b = '2025' m = 4 c = 45

5   Pass
x = 55 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 55 tf_correct = logical 1 a = 3025 b = '3025' m = 4 c = 55

6   Pass
x = 99 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 99 tf_correct = logical 1 a = 9801 b = '9801' m = 4 c = 99

7   Pass
x = 297 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 297 tf_correct = logical 1 a = 88209 b = '88209' m = 5 c = 297

8   Pass
x = 703 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 703 tf_correct = logical 1 a = 494209 b = '494209' m = 6 c = 703

9   Pass
x = 999 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 999 tf_correct = logical 1 a = 998001 b = '998001' m = 6 c = 999

10   Pass
x = 2223 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 2223 tf_correct = logical 1 a = 4941729 b = '4941729' m = 7 c = 2223

11   Pass
x = 2728 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 2728 tf_correct = logical 1 a = 7441984 b = '7441984' m = 7 c = 2728

12   Pass
x = 4950 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 4950 tf_correct = logical 1 a = 24502500 b = '24502500' m = 8 c = 4950

13   Pass
x = 5050 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 5050 tf_correct = logical 1 a = 25502500 b = '25502500' m = 8 c = 5050

14   Pass
x = 7272 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 7272 tf_correct = logical 1 a = 52881984 b = '52881984' m = 8 c = 7272

15   Pass
x = 7777 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 7777 tf_correct = logical 1 a = 60481729 b = '60481729' m = 8 c = 7777

16   Pass
x = 9999 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 9999 tf_correct = logical 1 a = 99980001 b = '99980001' m = 8 c = 9999

17   Pass
x = 17344 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 17344 tf_correct = logical 1 a = 300814336 b = '300814336' m = 9 c = 17344

18   Pass
x = 22222 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 22222 tf_correct = logical 1 a = 493817284 b = '493817284' m = 9 c = 22222

19   Pass
x = 77778 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 77778 tf_correct = logical 1 a = 6.0494e+09 b = '6049417284' m = 10 c = 77778

20   Pass
x = 82656 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 82656 tf_correct = logical 1 a = 6.8320e+09 b = '6832014336' m = 10 c = 82656

21   Pass
x = 95121 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 95121 tf_correct = logical 1 a = 9.0480e+09 b = '9048004641' m = 10 c = 95121

22   Pass
x = 99999 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 99999 tf_correct = logical 1 a = 9.9998e+09 b = '9999800001' m = 10 c = 99999

23   Pass
x = 142857 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 142857 tf_correct = logical 1 a = 2.0408e+10 b = '20408122449' m = 11 c = 142857

24   Pass
x = 148149 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 148149 tf_correct = logical 1 a = 2.1948e+10 b = '21948126201' m = 11 c = 148149

25   Pass
x = 181819 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 181819 tf_correct = logical 1 a = 3.3058e+10 b = '33058148761' m = 11 c = 181819

26   Pass
x = 187110 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 187110 tf_correct = logical 1 a = 3.5010e+10 b = '35010152100' m = 11 c = 187110

27   Pass
x = 208495 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 208495 tf_correct = logical 1 a = 4.3470e+10 b = '43470165025' m = 11 c = 208495

28   Pass
x = 318682 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 318682 tf_correct = logical 1 a = 1.0156e+11 b = '101558217124' m = 12 c = 318682

29   Pass
x = 329967 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 329967 tf_correct = logical 1 a = 1.0888e+11 b = '108878221089' m = 12 c = 329967

30   Pass
x = 351352 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 351352 tf_correct = logical 1 a = 1.2345e+11 b = '123448227904' m = 12 c = 351352

31   Pass
x = 356643 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 356643 tf_correct = logical 1 a = 1.2719e+11 b = '127194229449' m = 12 c = 356643

32   Pass
x = 390313 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 390313 tf_correct = logical 1 a = 1.5234e+11 b = '152344237969' m = 12 c = 390313

33   Pass
x = 461539 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 461539 tf_correct = logical 1 a = 2.1302e+11 b = '213018248521' m = 12 c = 461539

34   Pass
x = 466830 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 466830 tf_correct = logical 1 a = 2.1793e+11 b = '217930248900' m = 12 c = 466830

35   Pass
x = 499500 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 499500 tf_correct = logical 1 a = 2.4950e+11 b = '249500250000' m = 12 c = 499500

36   Pass
x = 500500 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 500500 tf_correct = logical 1 a = 2.5050e+11 b = '250500250000' m = 12 c = 500500

37   Pass
x = 533170 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 533170 tf_correct = logical 1 a = 2.8427e+11 b = '284270248900' m = 12 c = 533170

38   Pass
x = 538461 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 538461 tf_correct = logical 1 a = 2.8994e+11 b = '289940248521' m = 12 c = 538461

39   Pass
x = 609687 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 609687 tf_correct = logical 1 a = 3.7172e+11 b = '371718237969' m = 12 c = 609687

40   Pass
x = 643357 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 643357 tf_correct = logical 1 a = 4.1391e+11 b = '413908229449' m = 12 c = 643357

41   Pass
x = 648648 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 648648 tf_correct = logical 1 a = 4.2074e+11 b = '420744227904' m = 12 c = 648648

42   Pass
x = 670033 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 670033 tf_correct = logical 1 a = 4.4894e+11 b = '448944221089' m = 12 c = 670033

43   Pass
x = 681318 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 681318 tf_correct = logical 1 a = 4.6419e+11 b = '464194217124' m = 12 c = 681318

44   Pass
x = 681319 tf_correct = false assert(isequal(kap(x),tf_correct))

x = 681319 tf_correct = logical 0 a = 4.6420e+11 b = '464195579761' m = 12 c = 1043956

45   Pass
x = 681320 tf_correct = false assert(isequal(kap(x),tf_correct))

x = 681320 tf_correct = logical 0 a = 4.6420e+11 b = '464196942400' m = 12 c = 1406596

### Community Treasure Hunt

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

Start Hunting!