Skip to content

Kaprekar Numbers are numbers whose square in that base can be split into 2 parts that add up to the original number.

Notifications You must be signed in to change notification settings

sjdthree/Kaprekar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Kaprekar

Kaprekar Numbers are numbers whose square in that base can be split into 2 parts that add up to the original number.

from twitter and @fermatslibrary: https://twitter.com/fermatslibrary/status/1192083979710713858

An example: 45 is a Kaprekar number, because 45² = 2025 and

20 + 25 = 45

9^2

45^2

297^2

7777^2

first some simple algebra: Implemented by adjusting digits, so seeking an x of 3 digits, the sum of two three-digit numbers is how I constructed it. Some implementations use this split as arbitrary.

x^2 = 1000y+z

x = y+z

where y and z are three digits

and therefore x is at least 3 digits or more

x^Z2 - x = 999y

x range: 100 - 1999 -- that is max range if y & z are 3 digits

SAMPLE OUTPUT:

from 100 to 100,000,000

winner: 297

x^2 = 88209 88 209

Check: 297 297

winner: 703

x^2 = 494209 494 209

Check: 703 703

winner: 999

x^2 = 998001 998 1

Check: 999 999

winner: 2223

x^2 = 4941729 494 1729

Check: 2223 2223

winner: 2728

x^2 = 7441984 744 1984

Check: 2728 2728

winner: 4950

x^2 = 24502500 2450 2500

Check: 4950 4950

winner: 5050

x^2 = 25502500 2550 2500

Check: 5050 5050

winner: 7272

x^2 = 52881984 5288 1984

Check: 7272 7272

winner: 7777

x^2 = 60481729 6048 1729

Check: 7777 7777

winner: 9999

x^2 = 99980001 9998 1

Check: 9999 9999

winner: 17344

x^2 = 300814336 3008 14336

Check: 17344 17344

winner: 22222

x^2 = 493817284 4938 17284

Check: 22222 22222

winner: 77778 x^2 = 6049417284 60494 17284 Check: 77778 77778

winner: 82656 x^2 = 6832014336 68320 14336 Check: 82656 82656

winner: 95121 x^2 = 9048004641 90480 4641 Check: 95121 95121

winner: 99999 x^2 = 9999800001 99998 1 Check: 99999 99999

winner: 142857 x^2 = 20408122449 20408 122449 Check: 142857 142857

winner: 148149 x^2 = 21948126201 21948 126201 Check: 148149 148149

winner: 181819 x^2 = 33058148761 33058 148761 Check: 181819 181819

winner: 187110 x^2 = 35010152100 35010 152100 Check: 187110 187110

winner: 208495 x^2 = 43470165025 43470 165025 Check: 208495 208495

winner: 318682 x^2 = 101558217124 101558 217124 Check: 318682 318682

winner: 329967 x^2 = 108878221089 108878 221089 Check: 329967 329967

winner: 351352 x^2 = 123448227904 123448 227904 Check: 351352 351352

winner: 356643 x^2 = 127194229449 127194 229449 Check: 356643 356643

winner: 390313 x^2 = 152344237969 152344 237969 Check: 390313 390313

winner: 461539 x^2 = 213018248521 213018 248521 Check: 461539 461539

winner: 466830 x^2 = 217930248900 217930 248900 Check: 466830 466830

winner: 499500 x^2 = 249500250000 249500 250000 Check: 499500 499500

winner: 500500 x^2 = 250500250000 250500 250000 Check: 500500 500500

winner: 533170 x^2 = 284270248900 284270 248900 Check: 533170 533170

winner: 538461 x^2 = 289940248521 289940 248521 Check: 538461 538461

winner: 609687 x^2 = 371718237969 371718 237969 Check: 609687 609687

winner: 643357 x^2 = 413908229449 413908 229449 Check: 643357 643357

winner: 648648 x^2 = 420744227904 420744 227904 Check: 648648 648648

winner: 670033 x^2 = 448944221089 448944 221089 Check: 670033 670033

winner: 681318 x^2 = 464194217124 464194 217124 Check: 681318 681318

winner: 791505 x^2 = 626480165025 626480 165025 Check: 791505 791505

winner: 812890 x^2 = 660790152100 660790 152100 Check: 812890 812890

winner: 818181 x^2 = 669420148761 669420 148761 Check: 818181 818181

winner: 851851 x^2 = 725650126201 725650 126201 Check: 851851 851851

winner: 857143 x^2 = 734694122449 734694 122449 Check: 857143 857143

winner: 961038 x^2 = 923594037444 923594 37444 Check: 961038 961038

winner: 994708 x^2 = 989444005264 989444 5264 Check: 994708 994708

winner: 999999 x^2 = 999998000001 999998 1 Check: 999999 999999

winner: 4444444 x^2 = 19753082469136 1975308 2469136 Check: 4444444 4444444

winner: 4927941 x^2 = 24284602499481 2428460 2499481 Check: 4927941 4927941

winner: 5072059 x^2 = 25725782499481 2572578 2499481 Check: 5072059 5072059

winner: 5555556 x^2 = 30864202469136 3086420 2469136 Check: 5555556 5555556

winner: 9372385 x^2 = 87841600588225 8784160 588225 Check: 9372385 9372385

winner: 9999999 x^2 = 99999980000001 9999998 1 Check: 9999999 9999999

About

Kaprekar Numbers are numbers whose square in that base can be split into 2 parts that add up to the original number.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages