PDA

View Full Version : Right Triangles



danbaron
25-05-2011, 07:11
For a right triangle, the Pythagorean theorem says that,

a^2 + b^2 = c^2.

If I am correct, here are all of the 1034 right triangles, for integer values of a, b, and c, such that a and b are not greater than 1000.

:o


' code --------------------------------------------------------------------------------------------------------------------------------------

#lang racket

(define list-list (list))

(define (list-integer-right-triangles n)
(define a 0)
(define b 0)
(define c 0)
(define count1 0)
(define count2 0)
(define (loop1)
(set! count1 (add1 count1))
(cond
((> count1 n) list-list)
(else
(set! count2 (- count1 1))
(loop2)
(loop1))))
(define (loop2)
(set! count2 (add1 count2))
(cond
((> count2 n))
(else
(set! a count1)
(set! b count2)
(set! c (sqrt (+ (expt a 2) (expt b 2))))
(when (= c (floor c)) (set! list-list (append list-list (list (list a b c)))))
(loop2))))
(loop1))

' REPL interactions -------------------------------------------------------------------------------------------------------------------------

Welcome to DrRacket, version 5.1 [3m].
Language: racket.

> (list-integer-right-triangles 1000)
'((3 4 5)
(5 12 13)
(6 8 10)
(7 24 25)
(8 15 17)
(9 12 15)
(9 40 41)
(10 24 26)
(11 60 61)
(12 16 20)
(12 35 37)
(13 84 85)
(14 48 50)
(15 20 25)
(15 36 39)
(15 112 113)
(16 30 34)
(16 63 65)
(17 144 145)
(18 24 30)
(18 80 82)
(19 180 181)
(20 21 29)
(20 48 52)
(20 99 101)
(21 28 35)
(21 72 75)
(21 220 221)
(22 120 122)
(23 264 265)
(24 32 40)
(24 45 51)
(24 70 74)
(24 143 145)
(25 60 65)
(25 312 313)
(26 168 170)
(27 36 45)
(27 120 123)
(27 364 365)
(28 45 53)
(28 96 100)
(28 195 197)
(29 420 421)
(30 40 50)
(30 72 78)
(30 224 226)
(31 480 481)
(32 60 68)
(32 126 130)
(32 255 257)
(33 44 55)
(33 56 65)
(33 180 183)
(33 544 545)
(34 288 290)
(35 84 91)
(35 120 125)
(35 612 613)
(36 48 60)
(36 77 85)
(36 105 111)
(36 160 164)
(36 323 325)
(37 684 685)
(38 360 362)
(39 52 65)
(39 80 89)
(39 252 255)
(39 760 761)
(40 42 58)
(40 75 85)
(40 96 104)
(40 198 202)
(40 399 401)
(41 840 841)
(42 56 70)
(42 144 150)
(42 440 442)
(43 924 925)
(44 117 125)
(44 240 244)
(44 483 485)
(45 60 75)
(45 108 117)
(45 200 205)
(45 336 339)
(46 528 530)
(48 55 73)
(48 64 80)
(48 90 102)
(48 140 148)
(48 189 195)
(48 286 290)
(48 575 577)
(49 168 175)
(50 120 130)
(50 624 626)
(51 68 85)
(51 140 149)
(51 432 435)
(52 165 173)
(52 336 340)
(52 675 677)
(54 72 90)
(54 240 246)
(54 728 730)
(55 132 143)
(55 300 305)
(56 90 106)
(56 105 119)
(56 192 200)
(56 390 394)
(56 783 785)
(57 76 95)
(57 176 185)
(57 540 543)
(58 840 842)
(60 63 87)
(60 80 100)
(60 91 109)
(60 144 156)
(60 175 185)
(60 221 229)
(60 297 303)
(60 448 452)
(60 899 901)
(62 960 962)
(63 84 105)
(63 216 225)
(63 280 287)
(63 660 663)
(64 120 136)
(64 252 260)
(64 510 514)
(65 72 97)
(65 156 169)
(65 420 425)
(66 88 110)
(66 112 130)
(66 360 366)
(68 285 293)
(68 576 580)
(69 92 115)
(69 260 269)
(69 792 795)
(70 168 182)
(70 240 250)
(72 96 120)
(72 135 153)
(72 154 170)
(72 210 222)
(72 320 328)
(72 429 435)
(72 646 650)
(75 100 125)
(75 180 195)
(75 308 317)
(75 560 565)
(75 936 939)
(76 357 365)
(76 720 724)
(77 264 275)
(77 420 427)
(78 104 130)
(78 160 178)
(78 504 510)
(80 84 116)
(80 150 170)
(80 192 208)
(80 315 325)
(80 396 404)
(80 798 802)
(81 108 135)
(81 360 369)
(84 112 140)
(84 135 159)
(84 187 205)
(84 245 259)
(84 288 300)
(84 437 445)
(84 585 591)
(84 880 884)
(85 132 157)
(85 204 221)
(85 720 725)
(87 116 145)
(87 416 425)
(88 105 137)
(88 165 187)
(88 234 250)
(88 480 488)
(88 966 970)
(90 120 150)
(90 216 234)
(90 400 410)
(90 672 678)
(91 312 325)
(91 588 595)
(92 525 533)
(93 124 155)
(93 476 485)
(95 168 193)
(95 228 247)
(95 900 905)
(96 110 146)
(96 128 160)
(96 180 204)
(96 247 265)
(96 280 296)
(96 378 390)
(96 572 580)
(96 765 771)
(98 336 350)
(99 132 165)
(99 168 195)
(99 440 451)
(99 540 549)
(100 105 145)
(100 240 260)
(100 495 505)
(100 621 629)
(102 136 170)
(102 280 298)
(102 864 870)
(104 153 185)
(104 195 221)
(104 330 346)
(104 672 680)
(105 140 175)
(105 208 233)
(105 252 273)
(105 360 375)
(105 608 617)
(105 784 791)
(108 144 180)
(108 231 255)
(108 315 333)
(108 480 492)
(108 725 733)
(108 969 975)
(110 264 286)
(110 600 610)
(111 148 185)
(111 680 689)
(112 180 212)
(112 210 238)
(112 384 400)
(112 441 455)
(112 780 788)
(114 152 190)
(114 352 370)
(115 252 277)
(115 276 299)
(116 837 845)
(117 156 195)
(117 240 267)
(117 520 533)
(117 756 765)
(119 120 169)
(119 408 425)
(120 126 174)
(120 160 200)
(120 182 218)
(120 209 241)
(120 225 255)
(120 288 312)
(120 350 370)
(120 391 409)
(120 442 458)
(120 594 606)
(120 715 725)
(120 896 904)
(121 660 671)
(123 164 205)
(123 836 845)
(124 957 965)
(125 300 325)
(126 168 210)
(126 432 450)
(126 560 574)
(128 240 272)
(128 504 520)
(129 172 215)
(129 920 929)
(130 144 194)
(130 312 338)
(130 840 850)
(132 176 220)
(132 224 260)
(132 351 375)
(132 385 407)
(132 475 493)
(132 720 732)
(133 156 205)
(133 456 475)
(135 180 225)
(135 324 351)
(135 352 377)
(135 600 615)
(136 255 289)
(136 273 305)
(136 570 586)
(138 184 230)
(138 520 538)
(140 147 203)
(140 171 221)
(140 225 265)
(140 336 364)
(140 480 500)
(140 693 707)
(140 975 985)
(141 188 235)
(143 780 793)
(143 924 935)
(144 165 219)
(144 192 240)
(144 270 306)
(144 308 340)
(144 420 444)
(144 567 585)
(144 640 656)
(144 858 870)
(145 348 377)
(145 408 433)
(147 196 245)
(147 504 525)
(150 200 250)
(150 360 390)
(150 616 634)
(152 285 323)
(152 345 377)
(152 714 730)
(153 204 255)
(153 420 447)
(153 680 697)
(154 528 550)
(154 840 854)
(155 372 403)
(155 468 493)
(156 208 260)
(156 320 356)
(156 455 481)
(156 495 519)
(156 667 685)
(159 212 265)
(160 168 232)
(160 231 281)
(160 300 340)
(160 384 416)
(160 630 650)
(160 792 808)
(161 240 289)
(161 552 575)
(162 216 270)
(162 720 738)
(165 220 275)
(165 280 325)
(165 396 429)
(165 532 557)
(165 900 915)
(168 224 280)
(168 270 318)
(168 315 357)
(168 374 410)
(168 425 457)
(168 490 518)
(168 576 600)
(168 775 793)
(168 874 890)
(170 264 314)
(170 408 442)
(171 228 285)
(171 528 555)
(171 760 779)
(174 232 290)
(174 832 850)
(175 288 337)
(175 420 455)
(175 600 625)
(176 210 274)
(176 330 374)
(176 468 500)
(176 693 715)
(176 960 976)
(177 236 295)
(180 189 261)
(180 240 300)
(180 273 327)
(180 299 349)
(180 385 425)
(180 432 468)
(180 525 555)
(180 663 687)
(180 800 820)
(180 891 909)
(182 624 650)
(183 244 305)
(184 345 391)
(184 513 545)
(185 444 481)
(185 672 697)
(186 248 310)
(186 952 970)
(189 252 315)
(189 340 389)
(189 648 675)
(189 840 861)
(190 336 386)
(190 456 494)
(192 220 292)
(192 256 320)
(192 360 408)
(192 494 530)
(192 560 592)
(192 756 780)
(195 216 291)
(195 260 325)
(195 400 445)
(195 468 507)
(195 748 773)
(196 315 371)
(196 672 700)
(198 264 330)
(198 336 390)
(198 880 902)
(200 210 290)
(200 375 425)
(200 480 520)
(200 609 641)
(200 990 1010)
(201 268 335)
(203 396 445)
(203 696 725)
(204 253 325)
(204 272 340)
(204 560 596)
(204 595 629)
(204 855 879)
(205 492 533)
(205 828 853)
(207 224 305)
(207 276 345)
(207 780 807)
(207 920 943)
(208 306 370)
(208 390 442)
(208 660 692)
(208 819 845)
(210 280 350)
(210 416 466)
(210 504 546)
(210 720 750)
(213 284 355)
(215 516 559)
(215 912 937)
(216 288 360)
(216 405 459)
(216 462 510)
(216 630 666)
(216 713 745)
(216 960 984)
(217 456 505)
(217 744 775)
(219 292 365)
(220 231 319)
(220 459 509)
(220 528 572)
(220 585 625)
(222 296 370)
(224 360 424)
(224 420 476)
(224 768 800)
(224 882 910)
(225 272 353)
(225 300 375)
(225 540 585)
(225 924 951)
(225 1000 1025)
(228 304 380)
(228 325 397)
(228 665 703)
(228 704 740)
(230 504 554)
(230 552 598)
(231 308 385)
(231 392 455)
(231 520 569)
(231 792 825)
(232 435 493)
(232 825 857)
(234 312 390)
(234 480 534)
(235 564 611)
(237 316 395)
(238 240 338)
(238 816 850)
(240 252 348)
(240 275 365)
(240 320 400)
(240 364 436)
(240 418 482)
(240 450 510)
(240 551 601)
(240 576 624)
(240 700 740)
(240 782 818)
(240 884 916)
(240 945 975)
(243 324 405)
(245 588 637)
(245 840 875)
(246 328 410)
(248 465 527)
(248 945 977)
(249 332 415)
(250 600 650)
(252 275 373)
(252 336 420)
(252 405 477)
(252 539 595)
(252 561 615)
(252 735 777)
(252 864 900)
(255 340 425)
(255 396 471)
(255 612 663)
(255 700 745)
(256 480 544)
(258 344 430)
(259 660 709)
(259 888 925)
(260 273 377)
(260 288 388)
(260 624 676)
(260 651 701)
(260 825 865)
(261 348 435)
(261 380 461)
(264 315 411)
(264 352 440)
(264 448 520)
(264 495 561)
(264 702 750)
(264 770 814)
(264 950 986)
(265 636 689)
(266 312 410)
(266 912 950)
(267 356 445)
(270 360 450)
(270 648 702)
(270 704 754)
(272 510 578)
(272 546 610)
(273 364 455)
(273 560 623)
(273 736 785)
(273 936 975)
(275 660 715)
(276 368 460)
(276 493 565)
(276 805 851)
(279 372 465)
(279 440 521)
(280 294 406)
(280 342 442)
(280 351 449)
(280 450 530)
(280 525 595)
(280 672 728)
(280 759 809)
(280 960 1000)
(282 376 470)
(285 380 475)
(285 504 579)
(285 684 741)
(285 880 925)
(287 816 865)
(287 984 1025)
(288 330 438)
(288 384 480)
(288 540 612)
(288 616 680)
(288 741 795)
(288 840 888)
(290 696 754)
(290 816 866)
(291 388 485)
(294 392 490)
(295 708 767)
(296 555 629)
(297 304 425)
(297 396 495)
(297 504 585)
(300 315 435)
(300 400 500)
(300 455 545)
(300 589 661)
(300 720 780)
(300 875 925)
(301 900 949)
(303 404 505)
(304 570 646)
(304 690 754)
(305 732 793)
(306 408 510)
(306 840 894)
(308 435 533)
(308 495 583)
(308 819 875)
(309 412 515)
(310 744 806)
(310 936 986)
(312 416 520)
(312 459 555)
(312 585 663)
(312 640 712)
(312 910 962)
(312 990 1038)
(315 420 525)
(315 572 653)
(315 624 699)
(315 756 819)
(315 988 1037)
(318 424 530)
(319 360 481)
(320 336 464)
(320 462 562)
(320 600 680)
(320 768 832)
(320 999 1049)
(321 428 535)
(322 480 578)
(324 432 540)
(324 693 765)
(324 945 999)
(325 360 485)
(325 780 845)
(327 436 545)
(328 615 697)
(330 440 550)
(330 560 650)
(330 792 858)
(333 444 555)
(333 644 725)
(335 804 871)
(336 377 505)
(336 385 511)
(336 448 560)
(336 527 625)
(336 540 636)
(336 630 714)
(336 748 820)
(336 850 914)
(336 980 1036)
(339 452 565)
(340 357 493)
(340 528 628)
(340 816 884)
(341 420 541)
(342 456 570)
(344 645 731)
(345 460 575)
(345 756 831)
(345 828 897)
(348 464 580)
(348 805 877)
(350 576 674)
(350 840 910)
(351 468 585)
(351 720 801)
(352 420 548)
(352 660 748)
(352 936 1000)
(354 472 590)
(355 852 923)
(357 360 507)
(357 476 595)
(357 980 1043)
(360 378 522)
(360 480 600)
(360 546 654)
(360 598 698)
(360 627 723)
(360 675 765)
(360 770 850)
(360 864 936)
(363 484 605)
(363 616 715)
(364 585 689)
(364 627 725)
(365 876 949)
(366 488 610)
(368 465 593)
(368 690 782)
(369 492 615)
(369 800 881)
(370 888 962)
(372 496 620)
(372 925 997)
(375 500 625)
(375 900 975)
(376 705 799)
(378 504 630)
(378 680 778)
(380 399 551)
(380 672 772)
(380 912 988)
(381 508 635)
(384 440 584)
(384 512 640)
(384 720 816)
(384 988 1060)
(385 552 673)
(385 924 1001)
(387 516 645)
(387 884 965)
(390 432 582)
(390 520 650)
(390 800 890)
(390 936 1014)
(392 630 742)
(392 735 833)
(393 524 655)
(395 948 1027)
(396 403 565)
(396 528 660)
(396 672 780)
(396 847 935)
(399 468 615)
(399 532 665)
(400 420 580)
(400 561 689)
(400 750 850)
(400 960 1040)
(402 536 670)
(405 540 675)
(405 972 1053)
(406 792 890)
(407 624 745)
(408 506 650)
(408 544 680)
(408 765 867)
(408 819 915)
(410 984 1066)
(411 548 685)
(414 448 610)
(414 552 690)
(415 996 1079)
(416 612 740)
(416 780 884)
(417 556 695)
(420 441 609)
(420 513 663)
(420 560 700)
(420 637 763)
(420 675 795)
(420 832 932)
(420 851 949)
(420 935 1025)
(423 564 705)
(424 795 901)
(425 660 785)
(426 568 710)
(429 460 629)
(429 572 715)
(429 700 821)
(429 728 845)
(429 880 979)
(432 495 657)
(432 576 720)
(432 665 793)
(432 810 918)
(432 924 1020)
(434 912 1010)
(435 580 725)
(438 584 730)
(440 462 638)
(440 525 685)
(440 825 935)
(440 918 1018)
(441 588 735)
(444 592 740)
(447 596 745)
(448 720 848)
(448 840 952)
(448 975 1073)
(450 544 706)
(450 600 750)
(451 780 901)
(453 604 755)
(455 504 679)
(455 528 697)
(456 608 760)
(456 650 794)
(456 855 969)
(459 612 765)
(460 483 667)
(462 616 770)
(462 784 910)
(464 777 905)
(464 870 986)
(465 620 775)
(468 595 757)
(468 624 780)
(468 960 1068)
(471 628 785)
(472 885 1003)
(473 864 985)
(474 632 790)
(475 840 965)
(476 480 676)
(476 765 901)
(477 636 795)
(480 504 696)
(480 550 730)
(480 640 800)
(480 693 843)
(480 728 872)
(480 836 964)
(480 900 1020)
(481 600 769)
(483 644 805)
(483 720 867)
(486 648 810)
(488 915 1037)
(489 652 815)
(492 656 820)
(495 660 825)
(495 840 975)
(495 952 1073)
(496 897 1025)
(496 930 1054)
(498 664 830)
(500 525 725)
(501 668 835)
(504 550 746)
(504 672 840)
(504 703 865)
(504 810 954)
(504 945 1071)
(507 676 845)
(510 680 850)
(510 792 942)
(512 960 1088)
(513 684 855)
(516 688 860)
(519 692 865)
(520 546 754)
(520 576 776)
(520 765 925)
(520 975 1105)
(522 696 870)
(522 760 922)
(525 700 875)
(525 864 1011)
(528 605 803)
(528 630 822)
(528 704 880)
(528 896 1040)
(528 990 1122)
(531 708 885)
(532 624 820)
(532 855 1007)
(533 756 925)
(534 712 890)
(537 716 895)
(540 567 783)
(540 629 829)
(540 720 900)
(540 819 981)
(540 897 1047)
(543 724 905)
(546 728 910)
(549 732 915)
(552 736 920)
(552 986 1130)
(555 572 797)
(555 740 925)
(558 744 930)
(558 880 1042)
(559 840 1009)
(560 588 812)
(560 684 884)
(560 702 898)
(560 900 1060)
(561 748 935)
(561 952 1105)
(564 752 940)
(567 756 945)
(570 760 950)
(573 764 955)
(576 660 876)
(576 768 960)
(576 943 1105)
(579 772 965)
(580 609 841)
(580 741 941)
(582 776 970)
(585 648 873)
(585 780 975)
(585 928 1097)
(588 784 980)
(588 945 1113)
(591 788 985)
(594 608 850)
(594 792 990)
(595 600 845)
(595 924 1099)
(597 796 995)
(600 630 870)
(600 800 1000)
(600 910 1090)
(603 804 1005)
(606 808 1010)
(609 812 1015)
(612 759 975)
(612 816 1020)
(615 728 953)
(615 820 1025)
(616 663 905)
(616 735 959)
(616 870 1066)
(616 990 1166)
(618 824 1030)
(620 651 899)
(620 861 1061)
(621 672 915)
(621 828 1035)
(624 715 949)
(624 832 1040)
(624 918 1110)
(627 836 1045)
(630 840 1050)
(633 844 1055)
(636 848 1060)
(638 720 962)
(639 852 1065)
(640 672 928)
(640 924 1124)
(642 856 1070)
(644 960 1156)
(645 812 1037)
(645 860 1075)
(648 864 1080)
(650 720 970)
(651 868 1085)
(654 872 1090)
(657 876 1095)
(660 693 957)
(660 779 1021)
(660 880 1100)
(660 989 1189)
(663 884 1105)
(665 780 1025)
(666 888 1110)
(669 892 1115)
(672 754 1010)
(672 770 1022)
(672 896 1120)
(675 816 1059)
(675 900 1125)
(678 904 1130)
(680 714 986)
(681 908 1135)
(682 840 1082)
(684 912 1140)
(684 975 1191)
(687 916 1145)
(690 920 1150)
(693 924 1155)
(696 697 985)
(696 928 1160)
(699 932 1165)
(700 735 1015)
(700 855 1105)
(702 936 1170)
(704 840 1096)
(704 903 1145)
(705 940 1175)
(705 992 1217)
(708 944 1180)
(711 948 1185)
(714 720 1014)
(714 952 1190)
(715 792 1067)
(717 956 1195)
(720 756 1044)
(720 825 1095)
(720 960 1200)
(723 964 1205)
(726 968 1210)
(729 972 1215)
(731 780 1069)
(732 976 1220)
(735 980 1225)
(736 930 1186)
(738 984 1230)
(740 777 1073)
(741 988 1235)
(744 817 1105)
(744 992 1240)
(747 996 1245)
(750 1000 1250)
(756 825 1119)
(760 798 1102)
(765 868 1157)
(768 880 1168)
(780 819 1131)
(780 864 1164)
(792 806 1130)
(792 945 1233)
(798 936 1230)
(799 960 1249)
(800 840 1160)
(816 935 1241)
(820 861 1189)
(828 896 1220)
(832 855 1193)
(833 840 1183)
(840 882 1218)
(845 936 1261)
(858 920 1258)
(860 903 1247)
(864 990 1314)
(880 924 1276)
(884 987 1325)
(891 912 1275)
(893 924 1285)
(900 945 1305)
(920 966 1334)
(940 987 1363)
(952 960 1352))
> (length list-list)
1034
>

Charles Pegge
25-05-2011, 10:45
Hi Dan,

About 5 weeks ago I thought about this problem in 3D. This is what I came up with.

I am interested in something as close to a cube as possible, so I restricted the range.

Among the more interesting results were: sides 42:42:49--->diagonal 77

simplifying to 6:6:7--->11

The simplest is 1:2:2--->3





uses "oxygen"

dim as string src="

'=============================
' the integer diagonal problem
'=============================
'
'looking for diagonals which have a simple ratio to the lengths of the sides.

' diagonal=sqrt x*x + y*y + z*z

' examples:
'========================
'
' 2D 3 4 --> diagonal 5
' 3D 2 3 6 --> diagonal 7

'========================

'==============================
'3D TABLE: DIAGONAL OF A CUBOID
'==============================


% max 100 'max diagonal
sys b,c,e,i,j,k,l,d[max]
single m
string pr,cr,se

cr=chr(13)+chr(10)
se=chr(9) 'tab
'
'===============================
e=100 'max diagonal
b=2 'min start
m=.4 'min side/diag ratio
'===============================
'
pr="TABLE OF CUBOID DIAGONAL INTEGERS" cr cr
pr+="n" se "x" se "y" se "z" se "diagonal" cr

for i=1 to e
d[i]=i*i
next

do
for i=b to e
for j= i to e
for k=j to e
for l=k to e
if d[i]+d[j]+d[k]=d[l] and i>e*m then
c+=1
if c>40 then exit do 'PROCESS FIRST 40 VALUES ONLY
pr+="" c se i se j se k se l cr
end if
next
next
next
next
exit do
end do

print pr

"

o2_asmo src
if len(o2_error) then
msgbox 0,o2_error
stop
else
o2_exec
end if

danbaron
25-05-2011, 21:08
Hi Charles.

It's interesting. I think I see what you mean, higher dimensional analogs of 2D shapes, having all integer dimensions.

I agree with your results.

I'll think about it too.

Dan

REDEBOLT
26-05-2011, 02:28
If I do a ctrl-c, it selects the entire post.
If try to drag the cursor, I only get part of the listing.
I have selected "Reply with Quote" and then select whats inside the code tags.
This works, but when I paste into Thinair, the listing is double-spaced.

Anyone have a better method?

:confused:

Regards,
Bob

Charles Pegge
26-05-2011, 05:22
That's a good idea Bob. The double spacing may be a browser problem. It does not happen with Google Chrome

The best solution is for us to post attachments if the programs are of any significant length.

Charles

danbaron
26-05-2011, 07:37
I think for a 3D right triangle, the Pythagorean theorem would become the same as your equation,

a^2 + b^2 + c^2 = d^2.

Here are the results for a, b, c and d all integers; and, a, b and c, not exceeding 100.

There were 171,700 trials, and, 890 successes.

:o


' code --------------------------------------------------------------------------------------------------------------------------------------

#lang racket

(define list-list (list))

(define (list-3D-integer-right-triangles n)
(define a 0)
(define b 0)
(define c 0)
(define d 0)
(define count1 0)
(define count2 0)
(define count3 0)
(define tot-count 0)
(set! list-list null)
(define (loop1)
(set! count1 (add1 count1))
(cond
((> count1 n) (values tot-count (length list-list) list-list))
(else
(set! count2 (- count1 1))
(loop2)
(loop1))))
(define (loop2)
(set! count2 (add1 count2))
(cond
((> count2 n))
(else
(set! count3 (- count2 1))
(loop3)
(loop2))))
(define (loop3)
(set! count3 (add1 count3))
(cond
((> count3 n))
(else
(set! tot-count (add1 tot-count))
(set! a count1)
(set! b count2)
(set! c count3)
(set! d (sqrt (+ (expt a 2) (expt b 2) (expt c 2))))
(when (= d (floor d)) (set! list-list (append list-list (list (list a b c d)))))
(loop3))))
(loop1))

' REPL interactions -------------------------------------------------------------------------------------------------------------------------

Welcome to DrRacket, version 5.1 [3m].
Language: racket.
> (list-3D-integer-right-triangles 100)
171700
890
'((1 2 2 3)
(1 4 8 9)
(1 6 18 19)
(1 8 32 33)
(1 10 50 51)
(1 12 12 17)
(1 12 72 73)
(1 14 98 99)
(1 18 30 35)
(1 22 46 51)
(1 28 76 81)
(1 32 100 105)
(1 34 38 51)
(1 44 68 81)
(1 68 80 105)
(1 70 70 99)
(2 3 6 7)
(2 4 4 6)
(2 5 14 15)
(2 6 9 11)
(2 7 26 27)
(2 8 16 18)
(2 9 42 43)
(2 10 11 15)
(2 10 25 27)
(2 11 62 63)
(2 12 36 38)
(2 13 86 87)
(2 14 23 27)
(2 14 49 51)
(2 16 64 66)
(2 18 39 43)
(2 18 81 83)
(2 19 34 39)
(2 20 100 102)
(2 21 42 47)
(2 22 59 63)
(2 24 24 34)
(2 26 29 39)
(2 26 83 87)
(2 29 82 87)
(2 31 94 99)
(2 34 53 63)
(2 36 60 70)
(2 43 46 63)
(2 44 92 102)
(2 49 86 99)
(2 54 63 83)
(2 59 94 111)
(2 61 62 87)
(2 66 99 119)
(2 68 76 102)
(3 4 12 13)
(3 6 6 9)
(3 6 22 23)
(3 8 36 37)
(3 10 54 55)
(3 12 24 27)
(3 12 76 77)
(3 14 18 23)
(3 16 24 29)
(3 18 54 57)
(3 24 28 37)
(3 24 56 61)
(3 24 96 99)
(3 26 66 71)
(3 30 46 55)
(3 36 36 51)
(3 36 68 77)
(3 42 94 103)
(3 46 54 71)
(3 50 90 103)
(3 54 90 105)
(3 56 84 101)
(3 80 96 125)
(3 92 96 133)
(4 4 7 9)
(4 5 20 21)
(4 6 12 14)
(4 7 32 33)
(4 8 8 12)
(4 8 19 21)
(4 9 48 49)
(4 10 28 30)
(4 11 68 69)
(4 12 18 22)
(4 12 39 41)
(4 13 16 21)
(4 13 92 93)
(4 14 52 54)
(4 16 32 36)
(4 16 67 69)
(4 17 28 33)
(4 18 84 86)
(4 20 22 30)
(4 20 50 54)
(4 23 52 57)
(4 24 33 41)
(4 24 72 76)
(4 27 72 77)
(4 28 35 45)
(4 28 46 54)
(4 28 98 102)
(4 32 47 57)
(4 32 61 69)
(4 33 36 49)
(4 36 78 86)
(4 38 68 78)
(4 40 97 105)
(4 42 84 94)
(4 44 53 69)
(4 45 72 85)
(4 48 48 68)
(4 52 58 78)
(4 52 77 93)
(4 72 87 113)
(4 77 88 117)
(4 84 87 121)
(4 86 92 126)
(5 6 30 31)
(5 8 44 45)
(5 10 10 15)
(5 10 62 63)
(5 12 84 85)
(5 20 40 45)
(5 30 90 95)
(5 38 50 63)
(5 40 56 69)
(5 48 60 77)
(5 54 78 95)
(5 60 60 85)
(5 70 86 111)
(6 6 7 11)
(6 6 17 19)
(6 7 42 43)
(6 8 24 26)
(6 9 18 21)
(6 9 58 59)
(6 10 15 19)
(6 10 33 35)
(6 11 78 79)
(6 12 12 18)
(6 12 44 46)
(6 13 18 23)
(6 14 27 31)
(6 14 57 59)
(6 15 42 45)
(6 16 72 74)
(6 17 30 35)
(6 18 27 33)
(6 18 43 47)
(6 18 89 91)
(6 21 22 31)
(6 21 78 81)
(6 22 63 67)
(6 23 54 59)
(6 24 48 54)
(6 26 87 91)
(6 27 38 47)
(6 27 74 79)
(6 28 36 46)
(6 30 33 45)
(6 30 75 81)
(6 32 48 58)
(6 33 58 67)
(6 35 42 55)
(6 38 69 79)
(6 39 82 91)
(6 41 42 59)
(6 42 69 81)
(6 42 85 95)
(6 43 66 79)
(6 48 56 74)
(6 54 73 91)
(6 58 75 95)
(6 60 92 110)
(6 62 87 107)
(6 67 78 103)
(6 72 72 102)
(6 73 78 107)
(6 74 93 119)
(6 78 87 117)
(6 90 95 131)
(7 8 56 57)
(7 10 74 75)
(7 12 96 97)
(7 14 14 21)
(7 14 22 27)
(7 16 28 33)
(7 24 60 65)
(7 26 70 75)
(7 28 56 63)
(7 30 30 43)
(7 40 40 57)
(7 48 84 97)
(7 74 98 123)
(7 84 84 119)
(8 8 14 18)
(8 8 31 33)
(8 9 12 17)
(8 9 72 73)
(8 10 40 42)
(8 11 16 21)
(8 11 92 93)
(8 12 24 28)
(8 12 51 53)
(8 14 64 66)
(8 16 16 24)
(8 16 38 42)
(8 16 79 81)
(8 18 96 98)
(8 19 40 45)
(8 20 25 33)
(8 20 56 60)
(8 21 48 53)
(8 24 27 37)
(8 24 36 44)
(8 24 78 82)
(8 26 32 42)
(8 28 49 57)
(8 29 88 93)
(8 31 100 105)
(8 32 64 72)
(8 34 56 66)
(8 36 63 73)
(8 36 81 89)
(8 40 44 60)
(8 40 100 108)
(8 44 95 105)
(8 48 66 82)
(8 49 64 81)
(8 51 96 109)
(8 53 76 93)
(8 56 70 90)
(8 56 92 108)
(8 64 67 93)
(8 64 94 114)
(8 66 72 98)
(8 69 84 109)
(8 80 85 117)
(8 96 96 136)
(9 10 90 91)
(9 12 20 25)
(9 12 36 39)
(9 18 18 27)
(9 18 38 43)
(9 18 66 69)
(9 22 54 59)
(9 24 32 41)
(9 28 84 89)
(9 30 50 59)
(9 32 36 49)
(9 36 72 81)
(9 42 54 69)
(9 42 98 107)
(9 46 78 91)
(9 48 72 87)
(9 62 66 91)
(9 72 84 111)
(10 10 23 27)
(10 10 49 51)
(10 12 60 62)
(10 14 35 39)
(10 14 73 75)
(10 15 30 35)
(10 16 88 90)
(10 18 51 55)
(10 20 20 30)
(10 22 71 75)
(10 25 70 75)
(10 26 95 99)
(10 30 45 55)
(10 37 50 63)
(10 40 80 90)
(10 41 62 75)
(10 45 54 71)
(10 50 55 75)
(10 57 90 107)
(10 65 74 99)
(10 76 100 126)
(11 12 24 29)
(11 18 42 47)
(11 22 22 33)
(11 22 58 63)
(11 28 88 93)
(11 36 48 61)
(11 42 66 79)
(11 44 52 69)
(11 44 88 99)
(11 58 94 111)
(11 74 82 111)
(12 12 14 22)
(12 12 21 27)
(12 12 34 38)
(12 12 71 73)
(12 14 84 86)
(12 15 16 25)
(12 15 60 63)
(12 16 21 29)
(12 16 48 52)
(12 16 99 101)
(12 18 36 42)
(12 19 48 53)
(12 20 30 38)
(12 20 66 70)
(12 21 28 37)
(12 21 56 61)
(12 21 96 99)
(12 24 24 36)
(12 24 31 41)
(12 24 41 49)
(12 24 57 63)
(12 24 88 92)
(12 26 36 46)
(12 27 44 53)
(12 28 54 62)
(12 29 96 101)
(12 30 84 90)
(12 31 36 49)
(12 32 69 77)
(12 33 64 73)
(12 34 60 70)
(12 36 37 53)
(12 36 54 66)
(12 36 67 77)
(12 36 86 94)
(12 39 48 63)
(12 39 88 97)
(12 42 44 62)
(12 44 57 73)
(12 44 99 109)
(12 47 84 97)
(12 48 59 77)
(12 48 96 108)
(12 51 84 99)
(12 52 81 97)
(12 54 76 94)
(12 56 72 92)
(12 59 60 85)
(12 60 66 90)
(12 60 95 113)
(12 64 96 116)
(12 70 84 110)
(12 72 99 123)
(12 82 84 118)
(12 88 99 133)
(12 96 97 137)
(13 14 34 39)
(13 16 40 45)
(13 24 72 77)
(13 26 26 39)
(13 26 82 87)
(13 50 70 87)
(13 52 76 93)
(13 66 78 103)
(13 76 88 117)
(14 14 47 51)
(14 14 97 99)
(14 17 46 51)
(14 18 21 31)
(14 18 63 67)
(14 21 42 49)
(14 22 29 39)
(14 22 83 87)
(14 23 70 75)
(14 27 90 95)
(14 28 28 42)
(14 28 44 54)
(14 31 38 51)
(14 32 56 66)
(14 35 98 105)
(14 38 77 87)
(14 39 42 59)
(14 42 63 77)
(14 42 93 103)
(14 47 86 99)
(14 58 79 99)
(14 60 60 86)
(14 62 91 111)
(14 70 77 105)
(14 70 85 111)
(14 73 98 123)
(14 80 80 114)
(15 18 26 35)
(15 18 90 93)
(15 20 60 65)
(15 24 40 49)
(15 30 30 45)
(15 30 58 67)
(15 36 52 65)
(15 36 80 89)
(15 42 50 67)
(15 42 70 83)
(15 60 64 89)
(15 70 90 115)
(15 90 94 131)
(16 16 28 36)
(16 16 62 66)
(16 17 52 57)
(16 18 24 34)
(16 20 37 45)
(16 20 80 84)
(16 22 32 42)
(16 23 76 81)
(16 24 48 56)
(16 27 96 101)
(16 28 47 57)
(16 28 61 69)
(16 32 32 48)
(16 32 59 69)
(16 32 76 84)
(16 36 93 101)
(16 37 56 69)
(16 38 80 90)
(16 40 50 66)
(16 41 68 81)
(16 42 96 106)
(16 47 64 81)
(16 48 54 74)
(16 48 72 88)
(16 52 64 84)
(16 55 88 105)
(16 56 98 114)
(16 63 72 97)
(16 69 72 101)
(16 80 88 120)
(16 89 92 129)
(17 20 20 33)
(17 24 84 89)
(17 26 94 99)
(17 32 44 57)
(17 34 34 51)
(17 46 86 99)
(17 56 56 81)
(18 18 21 33)
(18 18 51 57)
(18 18 79 83)
(18 19 66 71)
(18 21 38 47)
(18 21 74 79)
(18 22 99 103)
(18 24 40 50)
(18 24 72 78)
(18 25 30 43)
(18 26 45 55)
(18 27 34 47)
(18 27 54 63)
(18 30 45 57)
(18 30 99 105)
(18 33 74 83)
(18 34 69 79)
(18 36 36 54)
(18 36 76 86)
(18 39 54 69)
(18 39 98 107)
(18 42 49 67)
(18 42 81 93)
(18 46 51 71)
(18 47 66 83)
(18 48 64 82)
(18 51 90 105)
(18 54 71 91)
(18 54 81 99)
(18 55 90 107)
(18 60 100 118)
(18 63 66 93)
(18 64 72 98)
(18 66 77 103)
(18 71 78 107)
(18 90 99 135)
(19 22 26 39)
(19 22 82 87)
(19 30 42 55)
(19 38 38 57)
(19 42 54 71)
(19 48 96 109)
(19 58 62 87)
(20 20 35 45)
(20 20 46 54)
(20 20 98 102)
(20 24 57 65)
(20 25 100 105)
(20 28 29 45)
(20 28 70 78)
(20 30 60 70)
(20 32 85 93)
(20 35 56 69)
(20 36 45 61)
(20 39 48 65)
(20 40 40 60)
(20 40 95 105)
(20 43 80 93)
(20 44 65 81)
(20 52 89 105)
(20 55 56 81)
(20 60 90 110)
(20 65 80 105)
(20 74 100 126)
(20 79 100 129)
(20 80 83 117)
(21 22 90 95)
(21 24 52 61)
(21 28 84 91)
(21 30 70 79)
(21 36 92 101)
(21 38 66 79)
(21 40 72 85)
(21 42 42 63)
(21 42 66 81)
(21 48 84 99)
(21 50 78 95)
(21 52 84 101)
(21 72 100 125)
(21 78 98 127)
(21 90 90 129)
(22 24 48 58)
(22 26 53 63)
(22 31 34 51)
(22 33 54 67)
(22 33 66 77)
(22 34 77 87)
(22 36 84 94)
(22 37 46 63)
(22 44 44 66)
(22 45 90 103)
(22 46 55 75)
(22 54 75 95)
(22 58 61 87)
(22 66 99 121)
(22 71 98 123)
(22 72 96 122)
(22 82 89 123)
(23 24 24 41)
(23 24 36 49)
(23 28 44 57)
(23 44 64 81)
(23 46 46 69)
(23 64 80 105)
(23 72 84 113)
(23 84 84 121)
(24 24 28 44)
(24 24 42 54)
(24 24 68 76)
(24 24 93 99)
(24 27 36 51)
(24 27 68 77)
(24 28 63 73)
(24 28 81 89)
(24 29 48 61)
(24 30 32 50)
(24 32 42 58)
(24 32 75 85)
(24 32 96 104)
(24 33 48 63)
(24 33 88 97)
(24 36 43 61)
(24 36 72 84)
(24 38 96 106)
(24 40 60 76)
(24 42 56 74)
(24 45 68 85)
(24 48 48 72)
(24 48 62 82)
(24 48 71 89)
(24 48 82 98)
(24 52 72 92)
(24 54 88 106)
(24 57 64 89)
(24 60 75 99)
(24 62 72 98)
(24 68 87 113)
(24 72 74 106)
(24 72 81 111)
(24 78 96 126)
(24 80 93 125)
(24 84 88 124)
(24 92 93 133)
(25 32 40 57)
(25 34 62 75)
(25 36 48 65)
(25 44 92 105)
(25 50 50 75)
(25 60 72 97)
(25 68 76 105)
(25 70 98 123)
(26 28 68 78)
(26 32 80 90)
(26 38 43 63)
(26 39 78 91)
(26 42 51 71)
(26 49 82 99)
(26 52 52 78)
(26 53 94 111)
(26 57 66 91)
(26 58 91 111)
(26 65 70 99)
(27 28 36 53)
(27 30 86 95)
(27 34 66 79)
(27 36 60 75)
(27 40 60 77)
(27 44 96 109)
(27 54 54 81)
(27 64 84 109)
(27 72 96 123)
(27 88 96 133)
(28 28 41 57)
(28 28 49 63)
(28 28 94 102)
(28 29 56 69)
(28 34 92 102)
(28 36 42 62)
(28 36 57 73)
(28 36 99 109)
(28 41 64 81)
(28 42 84 98)
(28 44 58 78)
(28 44 77 93)
(28 56 56 84)
(28 56 88 108)
(28 62 76 102)
(28 68 91 117)
(28 75 96 125)
(28 78 84 118)
(29 48 84 101)
(29 58 58 87)
(30 30 35 55)
(30 30 41 59)
(30 30 69 81)
(30 30 85 95)
(30 33 50 67)
(30 33 70 83)
(30 35 54 71)
(30 36 52 70)
(30 42 65 83)
(30 45 46 71)
(30 45 90 105)
(30 48 80 98)
(30 50 75 95)
(30 54 97 115)
(30 55 66 91)
(30 58 69 95)
(30 60 60 90)
(30 65 90 115)
(30 75 98 127)
(30 78 79 115)
(30 84 100 134)
(31 38 86 99)
(31 40 92 105)
(31 42 42 67)
(31 46 82 99)
(31 58 74 99)
(31 62 62 93)
(31 90 90 131)
(32 32 56 72)
(32 35 80 93)
(32 36 48 68)
(32 40 74 90)
(32 43 76 93)
(32 44 64 84)
(32 48 51 77)
(32 48 96 112)
(32 49 56 81)
(32 51 60 85)
(32 56 67 93)
(32 56 94 114)
(32 64 64 96)
(32 65 76 105)
(32 72 81 113)
(32 76 83 117)
(32 80 100 132)
(32 81 84 121)
(33 36 72 87)
(33 38 66 83)
(33 44 48 73)
(33 56 72 97)
(33 66 66 99)
(33 68 84 113)
(33 92 96 137)
(34 37 38 63)
(34 38 55 75)
(34 40 40 66)
(34 42 63 83)
(34 63 90 115)
(34 64 88 114)
(34 66 93 119)
(34 68 68 102)
(35 38 70 87)
(35 40 44 69)
(35 50 62 87)
(35 60 84 109)
(35 70 70 105)
(35 72 96 125)
(35 86 98 135)
(36 36 42 66)
(36 36 63 81)
(36 36 73 89)
(36 37 96 109)
(36 42 76 94)
(36 43 84 101)
(36 44 93 109)
(36 45 48 75)
(36 48 63 87)
(36 48 80 100)
(36 48 91 109)
(36 50 60 86)
(36 52 90 110)
(36 54 68 94)
(36 55 60 89)
(36 60 90 114)
(36 61 72 101)
(36 63 84 111)
(36 72 72 108)
(36 72 93 123)
(36 76 87 121)
(36 84 98 134)
(36 88 93 133)
(37 46 94 111)
(37 74 74 111)
(38 41 50 75)
(38 44 52 78)
(38 46 79 99)
(38 54 99 119)
(38 59 86 111)
(38 60 84 110)
(38 76 76 114)
(39 48 64 89)
(39 52 72 97)
(39 54 62 91)
(39 62 78 107)
(39 78 78 117)
(40 40 70 90)
(40 40 92 108)
(40 41 88 105)
(40 44 55 81)
(40 45 48 77)
(40 45 60 85)
(40 55 80 105)
(40 56 58 90)
(40 60 87 113)
(40 64 73 105)
(40 71 100 129)
(40 72 90 122)
(40 78 96 130)
(40 80 80 120)
(40 91 100 141)
(41 62 98 123)
(41 82 82 123)
(42 42 49 77)
(42 42 89 107)
(42 46 87 107)
(42 47 54 83)
(42 50 69 95)
(42 54 63 93)
(42 54 77 103)
(42 66 67 103)
(42 66 73 107)
(42 66 87 117)
(42 69 98 127)
(42 70 81 115)
(42 78 91 127)
(42 81 94 131)
(42 84 84 126)
(43 52 64 93)
(43 64 88 117)
(43 86 86 129)
(44 44 77 99)
(44 48 96 116)
(44 62 68 102)
(44 69 72 109)
(44 74 92 126)
(44 79 92 129)
(44 88 88 132)
(45 50 78 103)
(45 54 78 105)
(45 60 100 125)
(45 90 90 135)
(46 47 74 99)
(46 48 48 82)
(46 48 72 98)
(46 53 86 111)
(46 54 57 91)
(46 56 88 114)
(46 57 78 107)
(46 59 82 111)
(46 92 92 138)
(47 54 90 115)
(47 60 60 97)
(47 94 94 141)
(48 48 56 88)
(48 48 84 108)
(48 54 72 102)
(48 56 63 97)
(48 56 69 101)
(48 58 96 122)
(48 60 64 100)
(48 64 84 116)
(48 66 96 126)
(48 72 86 122)
(48 76 81 121)
(48 84 97 137)
(48 96 96 144)
(49 50 70 99)
(49 72 72 113)
(49 72 84 121)
(49 76 92 129)
(49 98 98 147)
(50 55 98 123)
(50 64 80 114)
(50 72 96 130)
(50 81 90 131)
(50 83 94 135)
(50 100 100 150)
(51 60 60 99)
(51 64 72 109)
(51 74 78 119)
(52 52 91 117)
(52 53 56 93)
(52 64 65 105)
(52 64 83 117)
(52 72 99 133)
(52 76 86 126)
(53 56 88 117)
(53 60 96 125)
(54 54 63 99)
(54 56 72 106)
(54 65 78 115)
(54 66 83 119)
(54 75 90 129)
(54 87 94 139)
(56 56 82 114)
(56 56 98 126)
(56 63 84 119)
(56 64 97 129)
(56 68 77 117)
(56 71 92 129)
(56 72 84 124)
(56 91 92 141)
(57 62 66 107)
(57 66 78 117)
(57 84 92 137)
(58 59 74 111)
(58 62 89 123)
(58 71 82 123)
(58 94 97 147)
(59 80 100 141)
(60 60 70 110)
(60 60 82 118)
(60 66 100 134)
(60 75 80 125)
(60 75 92 133)
(60 84 87 135)
(60 90 92 142)
(61 66 78 119)
(61 70 98 135)
(62 84 84 134)
(63 66 70 115)
(63 66 94 131)
(63 84 88 137)
(63 84 100 145)
(64 68 89 129)
(64 72 96 136)
(66 66 77 121)
(66 86 87 139)
(66 88 96 146)
(67 70 94 135)
(68 74 76 126)
(68 76 79 129)
(68 80 80 132)
(69 72 72 123)
(69 72 88 133)
(69 78 98 143)
(70 70 73 123)
(70 77 86 135)
(70 80 88 138)
(70 90 99 151)
(72 72 84 132)
(72 90 96 150)
(74 82 97 147)
(75 82 90 143)
(76 82 100 150)
(77 84 96 149)
(78 78 91 143)
(80 84 87 145)
(80 90 96 154)
(84 84 98 154)
(85 100 100 165)
(86 91 98 159)
(88 88 89 153)
(92 96 96 164))
>

danbaron
26-05-2011, 10:44
You can see below (I didn't show the lists), that if you allow the maximum dimension for one of the three "sides" of the triangle to be 700, then, there are 57,411,900 trials, and, 41,992 successes.

Incidentally, you said you wanted to get as close to a cube as you could.

I think it is impossible to get a cube if a, b, c and d are all integers.

If, a = b = c, then, you basically have,

3 * x^2 = y^2.

In that case,

y = sqrt(3) * x.


' REPL interactions ----------------------------------------------------------------------------------------------------

Welcome to DrRacket, version 5.1 [3m].
Language: racket.
> (list-3D-integer-right-triangles 400)
10746800
13801
> (list-3D-integer-right-triangles 500)
20958500
21436
> (list-3D-integer-right-triangles 600)
36180200
30932
> (list-3D-integer-right-triangles 700)
57411900
41992
>

Charles Pegge
26-05-2011, 10:49
Dan,

It should get easier as we go up the dimensions as there are more degrees of freedom.

the 4d hypoteneuse has a very simple solution:

1:1:1:1--->2.

Similarly 9d: 1:1:1:1:1:1:1:1:1--->3

and 16d, 25d, 36d likewise.


Charles

danbaron
26-05-2011, 19:47
Yes.

(I was not going to put this sentence, but, the forum complained that my message must be at least 10 characters.)

:p

Dan

Charles Pegge
26-05-2011, 20:48
Yes .

ErosOlmi
26-05-2011, 21:21
If I do a ctrl-c, it selects the entire post.
If try to drag the cursor, I only get part of the listing.
I have selected "Reply with Quote" and then select whats inside the code tags.
This works, but when I paste into Thinair, the listing is double-spaced.

Anyone have a better method?

:confused:

Regards,
Bob

double click and it select all in a code block
than right click and copy
than paste into thinAir

Please be sure to have latest thinBasic version: http://www.thinbasic.com/community/showthread.php?11148-thinBasic-Beta-1.8.7.0

danbaron
27-05-2011, 00:46
Maybe?











ppppppppppp

danbaron
27-05-2011, 00:56
I tried it for 4D.

For n = 200, I got 68,685,050 trials, and 124,768 successes.

I showed the list for n = 30.

Then, I extracted the 4D cubes.

----------------------------------------------------------------

Is there a better word than, "I", when I am the one using it?


yes
no
undecided
no comment

:oops: :twisted:


' code -----------------------------------------------------------------------------------------------------------------

#lang racket

(define list-list (list))
(define selection-list (list))

(define (list-4D-integer-right-triangles n)
(define a 0)
(define b 0)
(define c 0)
(define d 0)
(define e 0)
(define count1 0)
(define count2 0)
(define count3 0)
(define count4 0)
(define tot-count 0)
(set! list-list null)
(define (loop1)
(set! count1 (add1 count1))
(cond
((> count1 n) (values tot-count (length list-list) list-list))
(else
(set! count2 (- count1 1))
(loop2)
(loop1))))
(define (loop2)
(set! count2 (add1 count2))
(cond
((> count2 n))
(else
(set! count3 (- count2 1))
(loop3)
(loop2))))
(define (loop3)
(set! count3 (add1 count3))
(cond
((> count3 n))
(else
(set! count4 (- count3 1))
(loop4)
(loop3))))
(define (loop4)
(set! count4 (add1 count4))
(cond
((> count4 n))
(else
(set! tot-count (add1 tot-count))
(set! a count1)
(set! b count2)
(set! c count3)
(set! d count4)
(set! e (sqrt (+ (expt a 2) (expt b 2) (expt c 2) (expt d 2))))
(when (= e (floor e)) (set! list-list (append list-list (list (list a b c d e)))))
(loop4))))
(loop1))

(define (extract-cubes l)
(set! selection-list null)
(define (loop l1)
(cond
((empty? l1) selection-list)
(else
(define test (car l1))
(when (= (first test) (second test) (third test) (fourth test)) (set! selection-list (append selection-list (list test))))
(loop (cdr l1)))))
(loop l))

' REPL interactions ----------------------------------------------------------------------------------------------------

Welcome to DrRacket, version 5.1 [3m].
Language: racket.

> (list-4D-integer-right-triangles 100)
4421275
16275

> (list-4D-integer-right-triangles 200)
68685050
124768

> (list-4D-integer-right-triangles 30)
40920
530
'((1 1 1 1 2)
(1 1 3 5 6)
(1 1 5 13 14)
(1 1 7 7 10)
(1 1 7 25 26)
(1 1 11 19 22)
(1 1 13 27 30)
(1 1 23 25 34)
(1 2 2 4 5)
(1 2 4 10 11)
(1 2 6 20 21)
(1 2 8 10 13)
(1 2 10 16 19)
(1 2 18 20 27)
(1 3 3 9 10)
(1 3 5 17 18)
(1 3 7 29 30)
(1 3 15 21 26)
(1 3 19 23 30)
(1 4 4 4 7)
(1 4 4 16 17)
(1 4 6 26 27)
(1 4 8 12 15)
(1 4 10 18 21)
(1 4 16 16 23)
(1 4 26 26 37)
(1 5 5 7 10)
(1 5 5 25 26)
(1 5 7 11 14)
(1 5 11 23 26)
(1 5 13 17 22)
(1 5 17 19 26)
(1 5 17 29 34)
(1 7 7 15 18)
(1 7 11 27 30)
(1 7 15 25 30)
(1 8 8 20 23)
(1 8 10 14 19)
(1 8 10 26 29)
(1 8 22 26 35)
(1 9 11 11 18)
(1 9 17 23 30)
(1 9 29 29 42)
(1 10 12 14 21)
(1 10 12 22 27)
(1 10 16 22 29)
(1 10 22 28 37)
(1 12 18 30 37)
(1 13 17 21 30)
(1 13 19 25 34)
(1 15 15 15 26)
(1 16 16 24 33)
(1 16 22 22 35)
(1 17 23 25 38)
(1 18 18 24 35)
(1 20 22 22 37)
(2 2 2 2 4)
(2 2 3 8 9)
(2 2 4 5 7)
(2 2 5 16 17)
(2 2 6 10 12)
(2 2 7 8 11)
(2 2 7 28 29)
(2 2 8 17 19)
(2 2 10 26 28)
(2 2 11 20 23)
(2 2 12 17 21)
(2 2 13 28 31)
(2 2 14 14 20)
(2 2 16 19 25)
(2 2 27 28 39)
(2 3 4 14 15)
(2 3 6 24 25)
(2 3 20 26 33)
(2 4 4 8 10)
(2 4 5 6 9)
(2 4 5 22 23)
(2 4 6 13 15)
(2 4 7 10 13)
(2 4 8 20 22)
(2 4 10 13 17)
(2 4 10 29 31)
(2 4 11 22 25)
(2 4 13 30 33)
(2 4 14 15 21)
(2 4 14 25 29)
(2 4 15 22 27)
(2 4 16 20 26)
(2 4 23 26 35)
(2 5 8 14 17)
(2 5 10 20 23)
(2 5 14 20 25)
(2 5 16 26 31)
(2 5 22 24 33)
(2 6 6 18 20)
(2 6 8 11 15)
(2 6 8 25 27)
(2 6 12 21 25)
(2 6 15 24 29)
(2 6 17 20 27)
(2 7 8 18 21)
(2 7 10 24 27)
(2 8 8 8 14)
(2 8 10 11 17)
(2 8 10 19 23)
(2 8 11 30 33)
(2 8 14 19 25)
(2 8 16 24 30)
(2 8 17 22 29)
(2 8 25 26 37)
(2 9 10 16 21)
(2 10 10 14 20)
(2 10 11 20 25)
(2 10 12 29 33)
(2 10 13 16 23)
(2 10 14 22 28)
(2 10 15 20 27)
(2 10 16 27 33)
(2 10 24 29 39)
(2 13 14 16 25)
(2 14 14 30 36)
(2 14 19 20 31)
(2 14 20 25 35)
(2 16 17 26 35)
(2 16 19 30 39)
(2 16 20 28 38)
(2 16 22 25 37)
(2 17 20 26 37)
(2 18 19 20 33)
(2 18 22 22 36)
(2 20 21 26 39)
(2 20 24 28 42)
(2 24 27 30 47)
(2 30 30 30 52)
(3 3 3 3 6)
(3 3 3 13 14)
(3 3 5 21 22)
(3 3 9 15 18)
(3 3 21 21 30)
(3 4 4 20 21)
(3 4 6 30 31)
(3 4 10 10 15)
(3 5 5 29 30)
(3 5 9 9 14)
(3 5 11 13 18)
(3 5 15 15 22)
(3 6 6 12 15)
(3 6 10 12 17)
(3 6 12 30 33)
(3 6 16 18 25)
(3 6 24 30 39)
(3 8 12 12 19)
(3 8 16 20 27)
(3 8 24 24 35)
(3 9 9 27 30)
(3 9 13 15 22)
(3 9 15 19 26)
(3 9 15 29 34)
(3 9 21 25 34)
(3 9 25 27 38)
(3 10 14 28 33)
(3 12 12 12 21)
(3 12 18 22 31)
(3 13 19 19 30)
(3 14 20 22 33)
(3 14 24 30 41)
(3 15 15 21 30)
(3 17 25 29 42)
(3 20 30 30 47)
(4 4 4 4 8)
(4 4 4 11 13)
(4 4 5 8 11)
(4 4 5 28 29)
(4 4 6 16 18)
(4 4 7 12 15)
(4 4 8 10 14)
(4 4 8 23 25)
(4 4 11 24 27)
(4 4 12 20 24)
(4 4 14 16 22)
(4 4 16 21 27)
(4 4 20 23 31)
(4 4 28 28 40)
(4 5 8 8 13)
(4 5 8 16 19)
(4 5 10 22 25)
(4 5 12 16 21)
(4 5 20 20 29)
(4 5 20 28 35)
(4 6 6 9 13)
(4 6 6 21 23)
(4 6 8 28 30)
(4 6 10 17 21)
(4 6 14 29 33)
(4 6 19 26 33)
(4 6 27 30 41)
(4 7 8 20 23)
(4 7 10 14 19)
(4 7 10 26 29)
(4 7 22 26 35)
(4 8 8 9 15)
(4 8 8 16 20)
(4 8 10 12 18)
(4 8 12 26 30)
(4 8 14 20 26)
(4 8 15 28 33)
(4 8 16 17 25)
(4 8 16 25 31)
(4 8 19 20 29)
(4 8 19 28 35)
(4 8 20 26 34)
(4 8 28 30 42)
(4 10 10 15 21)
(4 10 10 25 29)
(4 10 13 26 31)
(4 10 14 23 29)
(4 10 16 28 34)
(4 10 17 18 27)
(4 10 19 22 31)
(4 10 22 25 35)
(4 10 26 27 39)
(4 11 14 14 23)
(4 11 22 30 39)
(4 12 12 15 23)
(4 12 13 20 27)
(4 12 15 24 31)
(4 12 16 22 30)
(4 12 20 23 33)
(4 13 16 20 29)
(4 13 16 28 35)
(4 13 20 28 37)
(4 14 22 23 35)
(4 16 16 16 28)
(4 16 16 29 37)
(4 16 17 20 31)
(4 16 20 22 34)
(4 16 25 28 41)
(4 18 21 30 41)
(4 20 20 28 40)
(4 20 23 24 39)
(4 21 28 28 45)
(4 22 25 30 45)
(4 25 28 28 47)
(4 26 26 29 47)
(5 5 5 5 10)
(5 5 5 11 14)
(5 5 7 15 18)
(5 5 11 27 30)
(5 5 15 25 30)
(5 6 8 10 15)
(5 6 12 18 23)
(5 6 18 24 31)
(5 6 26 28 39)
(5 7 7 19 22)
(5 7 9 13 18)
(5 7 11 17 22)
(5 7 23 29 38)
(5 8 8 24 27)
(5 8 10 10 17)
(5 8 10 30 33)
(5 8 14 26 31)
(5 8 18 26 33)
(5 9 13 25 30)
(5 10 10 20 25)
(5 11 13 13 22)
(5 11 13 19 26)
(5 11 13 29 34)
(5 11 15 23 30)
(5 12 26 26 39)
(5 13 25 25 38)
(5 13 27 29 42)
(5 14 16 22 31)
(5 14 20 30 39)
(5 14 26 28 41)
(5 15 17 19 30)
(5 16 18 22 33)
(5 16 28 28 43)
(5 17 17 29 38)
(5 19 23 23 38)
(5 20 20 20 35)
(5 24 30 30 49)
(5 25 25 29 46)
(6 6 6 6 12)
(6 6 6 26 28)
(6 6 8 15 19)
(6 6 9 24 27)
(6 6 12 15 21)
(6 6 12 25 29)
(6 6 18 30 36)
(6 6 21 24 33)
(6 7 10 16 21)
(6 8 10 23 27)
(6 8 15 30 35)
(6 8 20 20 30)
(6 9 10 12 19)
(6 9 18 20 29)
(6 9 18 28 35)
(6 9 24 26 37)
(6 10 13 28 33)
(6 10 18 18 28)
(6 10 22 26 36)
(6 10 30 30 44)
(6 11 12 18 25)
(6 11 16 26 33)
(6 12 12 24 30)
(6 12 15 18 27)
(6 12 17 30 37)
(6 12 20 24 34)
(6 12 21 30 39)
(6 13 20 22 33)
(6 13 24 30 41)
(6 15 16 18 29)
(6 15 18 28 37)
(6 16 24 24 38)
(6 17 18 24 35)
(6 18 26 30 44)
(6 23 26 28 45)
(6 24 24 24 42)
(7 7 7 7 14)
(7 7 7 23 26)
(7 7 17 17 26)
(7 7 19 21 30)
(7 7 23 23 34)
(7 8 8 28 31)
(7 8 16 16 25)
(7 8 20 24 33)
(7 8 28 28 41)
(7 10 16 18 27)
(7 10 20 26 35)
(7 11 17 21 30)
(7 11 19 25 34)
(7 12 18 18 29)
(7 13 13 17 26)
(7 14 14 20 29)
(7 14 14 28 35)
(7 15 21 21 34)
(7 15 21 27 38)
(7 16 16 20 31)
(7 17 17 23 34)
(7 18 24 30 43)
(7 19 25 27 42)
(7 20 26 30 45)
(7 28 28 28 49)
(8 8 8 8 16)
(8 8 8 13 19)
(8 8 8 22 26)
(8 8 10 16 22)
(8 8 12 13 21)
(8 8 14 24 30)
(8 8 16 20 28)
(8 8 16 29 35)
(8 8 20 29 37)
(8 9 10 14 21)
(8 9 10 22 27)
(8 9 18 30 37)
(8 10 10 19 25)
(8 10 11 26 31)
(8 10 13 14 23)
(8 10 14 27 33)
(8 10 16 16 26)
(8 10 21 22 33)
(8 10 23 26 37)
(8 10 26 29 41)
(8 11 12 20 27)
(8 11 16 20 29)
(8 11 16 28 35)
(8 11 20 28 37)
(8 12 12 18 26)
(8 12 16 25 33)
(8 12 21 24 35)
(8 12 23 28 39)
(8 13 14 14 25)
(8 14 17 26 35)
(8 14 19 30 39)
(8 14 20 28 38)
(8 14 22 25 37)
(8 15 20 20 33)
(8 16 16 18 30)
(8 16 20 24 36)
(8 16 24 25 39)
(8 19 20 20 35)
(8 20 20 30 42)
(8 22 25 26 43)
(8 22 28 28 46)
(8 24 24 30 46)
(9 9 9 9 18)
(9 9 15 17 26)
(9 9 21 29 38)
(9 10 12 30 35)
(9 11 13 23 30)
(9 11 15 27 34)
(9 12 12 16 25)
(9 12 18 26 35)
(9 12 30 30 45)
(9 13 17 19 30)
(9 14 14 16 27)
(9 15 15 25 34)
(9 15 27 27 42)
(9 16 20 28 39)
(9 22 26 28 45)
(9 23 23 25 42)
(10 10 10 10 20)
(10 10 10 22 28)
(10 10 13 16 25)
(10 10 14 30 36)
(10 10 19 20 31)
(10 10 20 25 35)
(10 11 16 22 31)
(10 11 20 30 39)
(10 11 26 28 41)
(10 12 13 26 33)
(10 12 14 17 27)
(10 12 15 30 37)
(10 12 16 20 30)
(10 12 19 22 33)
(10 13 24 26 39)
(10 14 16 17 29)
(10 14 17 28 37)
(10 14 18 26 36)
(10 14 20 23 35)
(10 14 21 28 39)
(10 15 18 24 35)
(10 16 18 29 39)
(10 16 20 20 34)
(10 16 22 23 37)
(10 16 22 29 41)
(10 17 26 28 43)
(10 19 22 24 39)
(10 20 25 30 45)
(10 22 26 26 44)
(10 22 28 29 47)
(10 26 28 29 49)
(11 11 11 11 22)
(11 11 17 25 34)
(11 11 19 29 38)
(11 13 13 21 30)
(11 13 23 25 38)
(11 14 14 24 33)
(11 17 25 27 42)
(11 18 20 26 39)
(11 19 21 29 42)
(11 20 22 26 41)
(11 21 21 21 38)
(11 23 25 29 46)
(11 24 24 24 43)
(12 12 12 12 24)
(12 12 12 23 31)
(12 12 15 24 33)
(12 12 16 30 38)
(12 12 19 24 35)
(12 12 24 30 42)
(12 13 18 18 31)
(12 14 21 30 41)
(12 15 18 26 37)
(12 15 24 24 39)
(12 16 17 20 33)
(12 16 28 29 45)
(12 18 18 27 39)
(12 18 20 24 38)
(12 18 22 27 41)
(12 18 29 30 47)
(12 20 24 27 43)
(12 23 26 26 45)
(12 24 24 27 45)
(13 13 13 13 26)
(13 13 17 23 34)
(13 14 14 20 31)
(13 14 16 30 39)
(13 14 18 20 33)
(13 15 23 29 42)
(13 16 20 20 35)
(13 17 19 25 38)
(13 20 20 20 37)
(13 21 23 25 42)
(14 14 14 14 28)
(14 14 16 21 33)
(14 14 20 27 39)
(14 16 17 22 35)
(14 17 20 22 37)
(14 20 21 22 39)
(14 20 23 30 45)
(14 24 27 30 49)
(15 15 15 15 30)
(15 16 16 28 39)
(15 17 25 25 42)
(15 18 20 30 43)
(15 18 24 30 45)
(15 24 30 30 51)
(15 28 30 30 53)
(16 16 16 16 32)
(16 16 16 26 38)
(16 16 24 26 42)
(16 16 27 28 45)
(16 17 20 24 39)
(16 18 20 28 42)
(16 18 27 30 47)
(16 20 20 25 41)
(16 20 26 28 46)
(16 21 24 24 43)
(16 22 22 25 43)
(16 26 28 28 50)
(17 17 17 17 34)
(17 19 25 29 46)
(17 20 22 26 43)
(17 22 24 26 45)
(17 23 29 29 50)
(18 18 18 18 36)
(18 18 24 25 43)
(18 20 25 26 45)
(19 19 19 19 38)
(20 20 20 20 40)
(20 20 21 28 45)
(20 20 25 28 47)
(20 22 22 29 47)
(20 22 26 29 49)
(20 24 28 29 51)
(20 25 26 30 51)
(20 28 28 29 53)
(21 21 21 21 42)
(21 22 24 30 49)
(21 28 30 30 55)
(22 22 22 22 44)
(23 23 23 23 46)
(24 24 24 24 48)
(25 25 25 25 50)
(26 26 26 26 52)
(27 27 27 27 54)
(28 28 28 28 56)
(29 29 29 29 58)
(30 30 30 30 60))

> (extract-cubes list-list)
'((1 1 1 1 2)
(2 2 2 2 4)
(3 3 3 3 6)
(4 4 4 4 8)
(5 5 5 5 10)
(6 6 6 6 12)
(7 7 7 7 14)
(8 8 8 8 16)
(9 9 9 9 18)
(10 10 10 10 20)
(11 11 11 11 22)
(12 12 12 12 24)
(13 13 13 13 26)
(14 14 14 14 28)
(15 15 15 15 30)
(16 16 16 16 32)
(17 17 17 17 34)
(18 18 18 18 36)
(19 19 19 19 38)
(20 20 20 20 40)
(21 21 21 21 42)
(22 22 22 22 44)
(23 23 23 23 46)
(24 24 24 24 48)
(25 25 25 25 50)
(26 26 26 26 52)
(27 27 27 27 54)
(28 28 28 28 56)
(29 29 29 29 58)
(30 30 30 30 60))
>

REDEBOLT
27-05-2011, 05:48
double click and it select all in a code block
than right click and copy
than paste into thinAir

Please be sure to have latest thinBasic version: http://www.thinbasic.com/community/showthread.php?11148-thinBasic-Beta-1.8.7.0

I have IE8 and TB 1.8.7.0

The double-click doesn't work.

Charles Pegge
27-05-2011, 06:02
Dan,

Speaking as a mind, fingers and PC collective, we think that you could use "We" or "One" or even use the passive tense but there is no more efficient word than "I".

Charles :)

danbaron
27-05-2011, 06:28
::begin communication to the (mechanism labeled by the) identifier (ID), Charles::

This ID does not know for certain what that ID means, concerning, "fingers". This ID can only guess that it refers to (collectively) typing on the keyboard (which, this ID (regrettably) thinks is on the fast road to extinction). Elsewise (otherwise), this ID thinks the word must have a particular societal (cultural) slang meaning, about which, this ID is unaware.

Now, upon further rumination, this ID becomes more convinced that, "fingers", does in fact, refer to typing.

::end communication from the ID Dan::

:cry: :bom:

ErosOlmi
27-05-2011, 10:13
I have IE8 and TB 1.8.7.0

The double-click doesn't work.

Bob,

this forum use the following syntax highlighter code: http://alexgorbatchev.com/SyntaxHighlighter

At the following page it describes the double click selection: http://alexgorbatchev.com/SyntaxHighlighter/whatsnew.html

I've tested it in every browser I could from IE7 to Opera to Chrome and here is working fine.

Can you please confirm at least double click for selecting all code box is working?

Ciao
Eros

zak
27-05-2011, 11:42
i don't know about the double click, this works well with me but after the syntax coloring appears on the page, sometimes it is delayed depending on web speed.
the best browser is opera for quickly show the syntax color. internet explorer sometimes delay the syntax color. any way the double click relief greatly from dragging the mouse over the code.

ErosOlmi
27-05-2011, 12:51
i don't know about the double click, this works well with me but after the syntax coloring appears on the page, sometimes it is delayed depending on web speed.
the best browser is opera for quickly show the syntax color. internet explorer sometimes delay the syntax color. any way the double click relief greatly from dragging the mouse over the code.

I use mainly Chrome because its Javascript engine is almost 20x faster than any IE up to IE8 and at least 2x faster that IE9. I also like very much Chrome because it is updated every 2 weeks while you never know when IEx is updated during Windows Update process.

Firefox Javascript engine is quite fast, Opera is sometimes in the middle between Chrome and Firefox.

IE9 is quite good but M$ has decided it is only for Windows 7 while other browsers, even if more advanced than IE9, work also on Windows XP

If you cannot install IE9 because you are under XP I strongly suggest you to change your browser.

REDEBOLT
28-05-2011, 09:48
I just now tried it with posts 1, 2, and 13.

It all works well, after a two or three second delay.

Thank you very much, Eros! :D

Regards,
Bob

P.S. I tried to change my profile to write a signature, but I couldn't find the setting. :(

Sorry for being a complainer. :(

ErosOlmi
28-05-2011, 11:14
P.S. I tried to change my profile to write a signature, but I couldn't find the setting. :(

Sorry for being a complainer. :(

I want other ... some thousand friends if they complain like you :p

Regarding editing your profile, check top menu and use "Forum actions\Edit profile"

Ciao
Eros