Cody

# Problem 166. Kaprekar numbers

Solution 16790

Submitted on 30 Jan 2012 by Franck Dernoncourt
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

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

a = 495616 n = 3 z = 495616 tf = 0

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

x = 9 tf_correct = 1 a = 81 n = 1 z = 81 tf = 1

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

x = 45 tf_correct = 1 a = 2025 n = 2 z = 2025 tf = 1

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

x = 55 tf_correct = 1 a = 3025 n = 2 z = 3025 tf = 1

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

x = 99 tf_correct = 1 a = 9801 n = 2 z = 9801 tf = 1

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

x = 297 tf_correct = 1 a = 88209 n = 3 z = 88209 tf = 1

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

x = 703 tf_correct = 1 a = 494209 n = 3 z = 494209 tf = 1

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

x = 999 tf_correct = 1 a = 998001 n = 3 z = 998001 tf = 1

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

x = 2223 tf_correct = 1 a = 4941729 n = 4 z = 4941729 tf = 1

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

x = 2728 tf_correct = 1 a = 7441984 n = 4 z = 7441984 tf = 1

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

x = 4950 tf_correct = 1 a = 24502500 n = 4 z = 24502500 tf = 1

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

x = 5050 tf_correct = 1 a = 25502500 n = 4 z = 25502500 tf = 1

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

x = 7272 tf_correct = 1 a = 52881984 n = 4 z = 52881984 tf = 1

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

x = 7777 tf_correct = 1 a = 60481729 n = 4 z = 60481729 tf = 1

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

x = 9999 tf_correct = 1 a = 99980001 n = 4 z = 99980001 tf = 1

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

x = 17344 tf_correct = 1 a = 300814336 n = 5 z = 300814336 tf = 1

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

x = 22222 tf_correct = 1 a = 493817284 n = 5 z = 493817284 tf = 1

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

x = 77778 tf_correct = 1 a = 6.0494e+09 n = 5 z = 6049417284 tf = 1

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

x = 82656 tf_correct = 1 a = 6.8320e+09 n = 5 z = 6832014336 tf = 1

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

x = 95121 tf_correct = 1 a = 9.0480e+09 n = 5 z = 9048004641 tf = 1

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

x = 99999 tf_correct = 1 a = 9.9998e+09 n = 5 z = 9999800001 tf = 1

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

x = 142857 tf_correct = 1 a = 2.0408e+10 n = 6 z = 20408122449 tf = 1

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

x = 148149 tf_correct = 1 a = 2.1948e+10 n = 6 z = 21948126201 tf = 1

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

x = 181819 tf_correct = 1 a = 3.3058e+10 n = 6 z = 33058148761 tf = 1

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

x = 187110 tf_correct = 1 a = 3.5010e+10 n = 6 z = 35010152100 tf = 1

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

x = 208495 tf_correct = 1 a = 4.3470e+10 n = 6 z = 43470165025 tf = 1

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

x = 318682 tf_correct = 1 a = 1.0156e+11 n = 6 z = 101558217124 tf = 1

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

x = 329967 tf_correct = 1 a = 1.0888e+11 n = 6 z = 108878221089 tf = 1

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

x = 351352 tf_correct = 1 a = 1.2345e+11 n = 6 z = 123448227904 tf = 1

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

x = 356643 tf_correct = 1 a = 1.2719e+11 n = 6 z = 127194229449 tf = 1

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

x = 390313 tf_correct = 1 a = 1.5234e+11 n = 6 z = 152344237969 tf = 1

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

x = 461539 tf_correct = 1 a = 2.1302e+11 n = 6 z = 213018248521 tf = 1

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

x = 466830 tf_correct = 1 a = 2.1793e+11 n = 6 z = 217930248900 tf = 1

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

x = 499500 tf_correct = 1 a = 2.4950e+11 n = 6 z = 249500250000 tf = 1

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

x = 500500 tf_correct = 1 a = 2.5050e+11 n = 6 z = 250500250000 tf = 1

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

x = 533170 tf_correct = 1 a = 2.8427e+11 n = 6 z = 284270248900 tf = 1

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

x = 538461 tf_correct = 1 a = 2.8994e+11 n = 6 z = 289940248521 tf = 1

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

x = 609687 tf_correct = 1 a = 3.7172e+11 n = 6 z = 371718237969 tf = 1

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

x = 643357 tf_correct = 1 a = 4.1391e+11 n = 6 z = 413908229449 tf = 1

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

x = 648648 tf_correct = 1 a = 4.2074e+11 n = 6 z = 420744227904 tf = 1

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

x = 670033 tf_correct = 1 a = 4.4894e+11 n = 6 z = 448944221089 tf = 1

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

x = 681318 tf_correct = 1 a = 4.6419e+11 n = 6 z = 464194217124 tf = 1

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

x = 681319 tf_correct = 0 a = 4.6420e+11 n = 6 z = 464195579761 tf = 0

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

x = 681320 tf_correct = 0 a = 4.6420e+11 n = 6 z = 464196942400 tf = 0

### Community Treasure Hunt

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

Start Hunting!