Question

#In class problem: A PT is a set of three positive integers # a<=b<=c such that...

#In class problem: A PT is a set of three positive integers # a<=b<=c such that a^2+b^2=c^2. #1) Find all the PTs such that c<=1000. Write a #program (in R) which prints them.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
for(c in 1:1000){#For c
    for(b in 1:c){#For b <= c
        for(a in 1:b){#For a <= b <= c
            if(a*a + b*b == c*c){#Only if this condition is satisfied
                cat(sprintf("PT = {%d, %d, %d}
", a, b, c));#Print set PT
            }
        }
    }
}




// Output for the following code.

$Rscript main.r
PT = {3, 4, 5}
PT = {6, 8, 10}
PT = {5, 12, 13}
PT = {9, 12, 15}
PT = {8, 15, 17}
PT = {12, 16, 20}
PT = {15, 20, 25}
PT = {7, 24, 25}
PT = {10, 24, 26}
PT = {20, 21, 29}
PT = {18, 24, 30}
PT = {16, 30, 34}
PT = {21, 28, 35}
PT = {12, 35, 37}
PT = {15, 36, 39}
PT = {24, 32, 40}
PT = {9, 40, 41}
PT = {27, 36, 45}
PT = {30, 40, 50}
PT = {14, 48, 50}
PT = {24, 45, 51}
PT = {20, 48, 52}
PT = {28, 45, 53}
PT = {33, 44, 55}
PT = {40, 42, 58}
PT = {36, 48, 60}
PT = {11, 60, 61}
PT = {39, 52, 65}
PT = {33, 56, 65}
PT = {25, 60, 65}
PT = {16, 63, 65}
PT = {32, 60, 68}
PT = {42, 56, 70}
PT = {48, 55, 73}
PT = {24, 70, 74}
PT = {45, 60, 75}
PT = {21, 72, 75}
PT = {30, 72, 78}
PT = {48, 64, 80}
PT = {18, 80, 82}
PT = {51, 68, 85}
PT = {40, 75, 85}
PT = {36, 77, 85}
PT = {13, 84, 85}
PT = {60, 63, 87}
PT = {39, 80, 89}
PT = {54, 72, 90}
PT = {35, 84, 91}
PT = {57, 76, 95}
PT = {65, 72, 97}
PT = {60, 80, 100}
PT = {28, 96, 100}
PT = {20, 99, 101}
PT = {48, 90, 102}
PT = {40, 96, 104}
PT = {63, 84, 105}
PT = {56, 90, 106}
PT = {60, 91, 109}
PT = {66, 88, 110}
PT = {36, 105, 111}
PT = {15, 112, 113}
PT = {69, 92, 115}
PT = {80, 84, 116}
PT = {45, 108, 117}
PT = {56, 105, 119}
PT = {72, 96, 120}
PT = {22, 120, 122}
PT = {27, 120, 123}
PT = {75, 100, 125}
PT = {44, 117, 125}
PT = {35, 120, 125}
PT = {78, 104, 130}
PT = {66, 112, 130}
PT = {50, 120, 130}
PT = {32, 126, 130}
PT = {81, 108, 135}
PT = {64, 120, 136}
PT = {88, 105, 137}
PT = {84, 112, 140}
PT = {55, 132, 143}
PT = {100, 105, 145}
PT = {87, 116, 145}
PT = {24, 143, 145}
PT = {17, 144, 145}
PT = {96, 110, 146}
PT = {48, 140, 148}
PT = {51, 140, 149}
PT = {90, 120, 150}
PT = {42, 144, 150}
PT = {72, 135, 153}
PT = {93, 124, 155}
PT = {60, 144, 156}
PT = {85, 132, 157}
PT = {84, 135, 159}
PT = {96, 128, 160}
PT = {36, 160, 164}
PT = {99, 132, 165}
PT = {119, 120, 169}
PT = {65, 156, 169}
PT = {102, 136, 170}
PT = {80, 150, 170}
PT = {72, 154, 170}
PT = {26, 168, 170}
PT = {52, 165, 173}
PT = {120, 126, 174}
PT = {105, 140, 175}
PT = {49, 168, 175}
PT = {78, 160, 178}
PT = {108, 144, 180}
PT = {19, 180, 181}
PT = {70, 168, 182}
PT = {33, 180, 183}
PT = {111, 148, 185}
PT = {104, 153, 185}
PT = {60, 175, 185}
PT = {57, 176, 185}
PT = {88, 165, 187}
PT = {114, 152, 190}
PT = {95, 168, 193}
PT = {130, 144, 194}
PT = {117, 156, 195}
PT = {99, 168, 195}
PT = {75, 180, 195}
PT = {48, 189, 195}
PT = {28, 195, 197}
PT = {120, 160, 200}
PT = {56, 192, 200}
PT = {40, 198, 202}
PT = {140, 147, 203}
PT = {96, 180, 204}
PT = {133, 156, 205}
PT = {123, 164, 205}
PT = {84, 187, 205}
PT = {45, 200, 205}
PT = {80, 192, 208}
PT = {126, 168, 210}
PT = {112, 180, 212}
PT = {129, 172, 215}
PT = {120, 182, 218}
PT = {144, 165, 219}
PT = {132, 176, 220}
PT = {140, 171, 221}
PT = {104, 195, 221}
PT = {85, 204, 221}
PT = {21, 220, 221}
PT = {72, 210, 222}
PT = {135, 180, 225}
PT = {63, 216, 225}
PT = {30, 224, 226}
PT = {60, 221, 229}
PT = {138, 184, 230}
PT = {160, 168, 232}
PT = {105, 208, 233}
PT = {90, 216, 234}
PT = {141, 188, 235}
PT = {112, 210, 238}
PT = {144, 192, 240}
PT = {120, 209, 241}
PT = {44, 240, 244}
PT = {147, 196, 245}
PT = {54, 240, 246}
PT = {95, 228, 247}
PT = {150, 200, 250}
PT = {88, 234, 250}
PT = {70, 240, 250}
PT = {153, 204, 255}
PT = {120, 225, 255}
PT = {108, 231, 255}
PT = {39, 252, 255}
PT = {32, 255, 257}
PT = {84, 245, 259}
PT = {156, 208, 260}
PT = {132, 224, 260}
PT = {100, 240, 260}
PT = {64, 252, 260}
PT = {180, 189, 261}
PT = {159, 212, 265}
PT = {140, 225, 265}
PT = {96, 247, 265}
PT = {23, 264, 265}
PT = {117, 240, 267}
PT = {69, 260, 269}
PT = {162, 216, 270}
PT = {128, 240, 272}
PT = {105, 252, 273}
PT = {176, 210, 274}
PT = {165, 220, 275}
PT = {77, 264, 275}
PT = {115, 252, 277}
PT = {168, 224, 280}
PT = {160, 231, 281}
PT = {171, 228, 285}
PT = {110, 264, 286}
PT = {63, 280, 287}
PT = {161, 240, 289}
PT = {136, 255, 289}
PT = {200, 210, 290}
PT = {174, 232, 290}
PT = {48, 286, 290}
PT = {34, 288, 290}
PT = {195, 216, 291}
PT = {192, 220, 292}
PT = {68, 285, 293}
PT = {177, 236, 295}
PT = {96, 280, 296}
PT = {102, 280, 298}
PT = {115, 276, 299}
PT = {180, 240, 300}
PT = {84, 288, 300}
PT = {60, 297, 303}
PT = {207, 224, 305}
PT = {183, 244, 305}
PT = {136, 273, 305}
PT = {55, 300, 305}
PT = {144, 270, 306}
PT = {186, 248, 310}
PT = {120, 288, 312}
PT = {25, 312, 313}
PT = {170, 264, 314}
PT = {189, 252, 315}
PT = {75, 308, 317}
PT = {168, 270, 318}
PT = {220, 231, 319}
PT = {192, 256, 320}
PT = {152, 285, 323}
PT = {204, 253, 325}
PT = {195, 260, 325}
PT = {165, 280, 325}
PT = {125, 300, 325}
PT = {91, 312, 325}
PT = {80, 315, 325}
PT = {36, 323, 325}
PT = {180, 273, 327}
PT = {72, 320, 328}
PT = {198, 264, 330}
PT = {108, 315, 333}
PT = {201, 268, 335}
PT = {175, 288, 337}
PT = {238, 240, 338}
PT = {130, 312, 338}
PT = {45, 336, 339}
PT = {204, 272, 340}
PT = {160, 300, 340}
PT = {144, 308, 340}
PT = {52, 336, 340}
PT = {207, 276, 345}
PT = {104, 330, 346}
PT = {240, 252, 348}
PT = {180, 299, 349}
PT = {210, 280, 350}
PT = {98, 336, 350}
PT = {135, 324, 351}
PT = {225, 272, 353}
PT = {213, 284, 355}
PT = {156, 320, 356}
PT = {168, 315, 357}
PT = {216, 288, 360}
PT = {38, 360, 362}
PT = {140, 336, 364}
PT = {240, 275, 365}
PT = {219, 292, 365}
PT = {76, 357, 365}
PT = {27, 364, 365}
PT = {66, 360, 366}
PT = {81, 360, 369}
PT = {222, 296, 370}
PT = {208, 306, 370}
PT = {120, 350, 370}
PT = {114, 352, 370}
PT = {196, 315, 371}
PT = {252, 275, 373}
PT = {176, 330, 374}
PT = {225, 300, 375}
PT = {132, 351, 375}
PT = {105, 360, 375}
PT = {260, 273, 377}
PT = {152, 345, 377}
PT = {145, 348, 377}
PT = {135, 352, 377}
PT = {228, 304, 380}
PT = {231, 308, 385}
PT = {190, 336, 386}
PT = {260, 288, 388}
PT = {189, 340, 389}
PT = {234, 312, 390}
PT = {198, 336, 390}
PT = {150, 360, 390}
PT = {96, 378, 390}
PT = {184, 345, 391}
PT = {56, 390, 394}
PT = {237, 316, 395}
PT = {228, 325, 397}
PT = {240, 320, 400}
PT = {112, 384, 400}
PT = {40, 399, 401}
PT = {155, 372, 403}
PT = {80, 396, 404}
PT = {243, 324, 405}
PT = {280, 294, 406}
PT = {132, 385, 407}
PT = {192, 360, 408}
PT = {120, 391, 409}
PT = {266, 312, 410}
PT = {246, 328, 410}
PT = {168, 374, 410}
PT = {90, 400, 410}
PT = {264, 315, 411}
PT = {249, 332, 415}
PT = {160, 384, 416}
PT = {252, 336, 420}
PT = {29, 420, 421}
PT = {224, 360, 424}
PT = {297, 304, 425}
PT = {255, 340, 425}
PT = {200, 375, 425}
PT = {180, 385, 425}
PT = {119, 408, 425}
PT = {87, 416, 425}
PT = {65, 420, 425}
PT = {77, 420, 427}
PT = {165, 396, 429}
PT = {258, 344, 430}
PT = {145, 408, 433}
PT = {300, 315, 435}
PT = {261, 348, 435}
PT = {72, 429, 435}
PT = {51, 432, 435}
PT = {240, 364, 436}
PT = {288, 330, 438}
PT = {264, 352, 440}
PT = {280, 342, 442}
PT = {208, 390, 442}
PT = {170, 408, 442}
PT = {42, 440, 442}
PT = {144, 420, 444}
PT = {267, 356, 445}
PT = {203, 396, 445}
PT = {195, 400, 445}
PT = {84, 437, 445}
PT = {153, 420, 447}
PT = {280, 351, 449}
PT = {270, 360, 450}
PT = {126, 432, 450}
PT = {99, 440, 451}
PT = {60, 448, 452}
PT = {273, 364, 455}
PT = {231, 392, 455}
PT = {175, 420, 455}
PT = {112, 441, 455}
PT = {168, 425, 457}
PT = {120, 442, 458}
PT = {216, 405, 459}
PT = {276, 368, 460}
PT = {261, 380, 461}
PT = {320, 336, 464}
PT = {279, 372, 465}
PT = {210, 416, 466}
PT = {180, 432, 468}
PT = {282, 376, 470}
PT = {255, 396, 471}
PT = {285, 380, 475}
PT = {133, 456, 475}
PT = {224, 420, 476}
PT = {252, 405, 477}
PT = {288, 384, 480}
PT = {319, 360, 481}
PT = {185, 444, 481}
PT = {156, 455, 481}
PT = {31, 480, 481}
PT = {240, 418, 482}
PT = {325, 360, 485}
PT = {291, 388, 485}
PT = {93, 476, 485}
PT = {44, 483, 485}
PT = {88, 480, 488}
PT = {294, 392, 490}
PT = {108, 480, 492}
PT = {340, 357, 493}
PT = {232, 435, 493}
PT = {155, 468, 493}
PT = {132, 475, 493}
PT = {190, 456, 494}
PT = {297, 396, 495}
PT = {300, 400, 500}
PT = {176, 468, 500}
PT = {140, 480, 500}
PT = {336, 377, 505}
PT = {303, 404, 505}
PT = {217, 456, 505}
PT = {100, 495, 505}
PT = {357, 360, 507}
PT = {195, 468, 507}
PT = {220, 459, 509}
PT = {306, 408, 510}
PT = {240, 450, 510}
PT = {216, 462, 510}
PT = {78, 504, 510}
PT = {336, 385, 511}
PT = {64, 510, 514}
PT = {309, 412, 515}
PT = {168, 490, 518}
PT = {156, 495, 519}
PT = {312, 416, 520}
PT = {264, 448, 520}
PT = {200, 480, 520}
PT = {128, 504, 520}
PT = {279, 440, 521}
PT = {360, 378, 522}
PT = {315, 420, 525}
PT = {147, 504, 525}
PT = {248, 465, 527}
PT = {318, 424, 530}
PT = {280, 450, 530}
PT = {192, 494, 530}
PT = {46, 528, 530}
PT = {308, 435, 533}
PT = {205, 492, 533}
PT = {117, 520, 533}
PT = {92, 525, 533}
PT = {234, 480, 534}
PT = {321, 428, 535}
PT = {138, 520, 538}
PT = {324, 432, 540}
PT = {341, 420, 541}
PT = {57, 540, 543}
PT = {256, 480, 544}
PT = {327, 436, 545}
PT = {300, 455, 545}
PT = {184, 513, 545}
PT = {33, 544, 545}
PT = {210, 504, 546}
PT = {352, 420, 548}
PT = {99, 540, 549}
PT = {330, 440, 550}
PT = {154, 528, 550}
PT = {380, 399, 551}
PT = {230, 504, 554}
PT = {333, 444, 555}
PT = {312, 459, 555}
PT = {180, 525, 555}
PT = {171, 528, 555}
PT = {165, 532, 557}
PT = {215, 516, 559}
PT = {336, 448, 560}
PT = {264, 495, 561}
PT = {320, 462, 562}
PT = {396, 403, 565}
PT = {339, 452, 565}
PT = {276, 493, 565}
PT = {75, 560, 565}
PT = {231, 520, 569}
PT = {342, 456, 570}
PT = {220, 528, 572}
PT = {126, 560, 574}
PT = {345, 460, 575}
PT = {161, 552, 575}
PT = {48, 575, 577}
PT = {322, 480, 578}
PT = {272, 510, 578}
PT = {285, 504, 579}
PT = {400, 420, 580}
PT = {348, 464, 580}
PT = {96, 572, 580}
PT = {68, 576, 580}
PT = {390, 432, 582}
PT = {308, 495, 583}
PT = {384, 440, 584}
PT = {351, 468, 585}
PT = {297, 504, 585}
PT = {225, 540, 585}
PT = {144, 567, 585}
PT = {136, 570, 586}
PT = {354, 472, 590}
PT = {84, 585, 591}
PT = {192, 560, 592}
PT = {368, 465, 593}
PT = {357, 476, 595}
PT = {280, 525, 595}
PT = {252, 539, 595}
PT = {91, 588, 595}
PT = {204, 560, 596}
PT = {230, 552, 598}
PT = {360, 480, 600}
PT = {168, 576, 600}
PT = {240, 551, 601}
PT = {363, 484, 605}
PT = {120, 594, 606}
PT = {420, 441, 609}
PT = {414, 448, 610}
PT = {366, 488, 610}
PT = {272, 546, 610}
PT = {110, 600, 610}
PT = {235, 564, 611}
PT = {288, 540, 612}
PT = {35, 612, 613}
PT = {399, 468, 615}
PT = {369, 492, 615}
PT = {252, 561, 615}
PT = {135, 600, 615}
PT = {105, 608, 617}
PT = {372, 496, 620}
PT = {273, 560, 623}
PT = {240, 576, 624}
PT = {375, 500, 625}
PT = {336, 527, 625}
PT = {220, 585, 625}
PT = {175, 600, 625}
PT = {50, 624, 626}
PT = {340, 528, 628}
PT = {429, 460, 629}
PT = {296, 555, 629}
PT = {204, 595, 629}
PT = {100, 621, 629}
PT = {378, 504, 630}
PT = {150, 616, 634}
PT = {381, 508, 635}
PT = {336, 540, 636}
PT = {245, 588, 637}
PT = {440, 462, 638}
PT = {384, 512, 640}
PT = {200, 609, 641}
PT = {387, 516, 645}
PT = {304, 570, 646}
PT = {408, 506, 650}
PT = {390, 520, 650}
PT = {330, 560, 650}
PT = {250, 600, 650}
PT = {182, 624, 650}
PT = {160, 630, 650}
PT = {72, 646, 650}
PT = {315, 572, 653}
PT = {360, 546, 654}
PT = {393, 524, 655}
PT = {144, 640, 656}
PT = {432, 495, 657}
PT = {396, 528, 660}
PT = {300, 589, 661}
PT = {420, 513, 663}
PT = {312, 585, 663}
PT = {255, 612, 663}
PT = {63, 660, 663}
PT = {399, 532, 665}
PT = {216, 630, 666}
PT = {460, 483, 667}
PT = {402, 536, 670}
PT = {121, 660, 671}
PT = {385, 552, 673}
PT = {350, 576, 674}
PT = {405, 540, 675}
PT = {189, 648, 675}
PT = {476, 480, 676}
PT = {260, 624, 676}
PT = {52, 675, 677}
PT = {90, 672, 678}
PT = {455, 504, 679}
PT = {408, 544, 680}
PT = {320, 600, 680}
PT = {288, 616, 680}
PT = {104, 672, 680}
PT = {440, 525, 685}
PT = {411, 548, 685}
PT = {156, 667, 685}
PT = {37, 684, 685}
PT = {180, 663, 687}
PT = {400, 561, 689}
PT = {364, 585, 689}
PT = {265, 636, 689}
PT = {111, 680, 689}
PT = {414, 552, 690}
PT = {208, 660, 692}
PT = {417, 556, 695}
PT = {480, 504, 696}
PT = {455, 528, 697}
PT = {328, 615, 697}
PT = {185, 672, 697}
PT = {153, 680, 697}
PT = {360, 598, 698}
PT = {315, 624, 699}
PT = {420, 560, 700}
PT = {196, 672, 700}
PT = {260, 651, 701}
PT = {270, 648, 702}
PT = {228, 665, 703}
PT = {423, 564, 705}
PT = {450, 544, 706}
PT = {140, 693, 707}
PT = {259, 660, 709}
PT = {426, 568, 710}
PT = {312, 640, 712}
PT = {336, 630, 714}
PT = {429, 572, 715}
PT = {363, 616, 715}
PT = {275, 660, 715}
PT = {176, 693, 715}
PT = {432, 576, 720}
PT = {360, 627, 723}
PT = {76, 720, 724}
PT = {500, 525, 725}
PT = {435, 580, 725}
PT = {364, 627, 725}
PT = {333, 644, 725}
PT = {203, 696, 725}
PT = {120, 715, 725}
PT = {85, 720, 725}
PT = {280, 672, 728}
PT = {480, 550, 730}
PT = {438, 584, 730}
PT = {152, 714, 730}
PT = {54, 728, 730}
PT = {344, 645, 731}
PT = {132, 720, 732}
PT = {108, 725, 733}
PT = {441, 588, 735}
PT = {162, 720, 738}
PT = {444, 592, 740}
PT = {416, 612, 740}
PT = {240, 700, 740}
PT = {228, 704, 740}
PT = {285, 684, 741}
PT = {392, 630, 742}
PT = {447, 596, 745}
PT = {407, 624, 745}
PT = {255, 700, 745}
PT = {216, 713, 745}
PT = {504, 550, 746}
PT = {352, 660, 748}
PT = {450, 600, 750}
PT = {264, 702, 750}
PT = {210, 720, 750}
PT = {520, 546, 754}
PT = {304, 690, 754}
PT = {290, 696, 754}
PT = {270, 704, 754}
PT = {453, 604, 755}
PT = {468, 595, 757}
PT = {456, 608, 760}
PT = {39, 760, 761}
PT = {420, 637, 763}
PT = {459, 612, 765}
PT = {360, 675, 765}
PT = {324, 693, 765}
PT = {117, 756, 765}
PT = {295, 708, 767}
PT = {481, 600, 769}
PT = {462, 616, 770}
PT = {96, 765, 771}
PT = {380, 672, 772}
PT = {195, 748, 773}
PT = {465, 620, 775}
PT = {217, 744, 775}
PT = {520, 576, 776}
PT = {252, 735, 777}
PT = {378, 680, 778}
PT = {171, 760, 779}
PT = {468, 624, 780}
PT = {396, 672, 780}
PT = {300, 720, 780}
PT = {192, 756, 780}
PT = {368, 690, 782}
PT = {540, 567, 783}
PT = {471, 628, 785}
PT = {425, 660, 785}
PT = {273, 736, 785}
PT = {56, 783, 785}
PT = {112, 780, 788}
PT = {474, 632, 790}
PT = {105, 784, 791}
PT = {432, 665, 793}
PT = {305, 732, 793}
PT = {168, 775, 793}
PT = {143, 780, 793}
PT = {456, 650, 794}
PT = {477, 636, 795}
PT = {420, 675, 795}
PT = {288, 741, 795}
PT = {69, 792, 795}
PT = {555, 572, 797}
PT = {376, 705, 799}
PT = {480, 640, 800}
PT = {224, 768, 800}
PT = {351, 720, 801}
PT = {80, 798, 802}
PT = {528, 605, 803}
PT = {483, 644, 805}
PT = {310, 744, 806}
PT = {207, 780, 807}
Add a comment
Know the answer?
Add Answer to:
#In class problem: A PT is a set of three positive integers # a<=b<=c such that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Let R be the relation on the set of ordered pairs of positive integers such that...

    Let R be the relation on the set of ordered pairs of positive integers such that ((a, b), (c, d)) Element R if and only if ad = bc. Show that R is an equivalence relation What is the equivalence class of of (1, 2), i.e. [(1, 2)]?

  • C++ Write a program that reads three positive integers (> 0) from the command line (one...

    C++ Write a program that reads three positive integers (> 0) from the command line (one at a time), then computes and prints the smallest entered number. Use if-else statements for three integer comparison. Example: Enter an integer: 5 Enter an integer: 23 Enter an integer: 7 The smallest number is: 5 Example 2: Enter an integer: 3 Enter an integer: 3 Enter an integer: 6 The smallest number is: 3 "The input must be positive number. The program should...

  • A. Create a java program that generates 1000 random integers. Write the 1000 random integers to...

    A. Create a java program that generates 1000 random integers. Write the 1000 random integers to a file using the Formatter class. B. Create a second java program that opens the file with the 1000 integers using the Scanner class. Read in the integers and find and print out the largest, smallest and the average of all 1000 numbers. C. Repeat A from above but use the BufferedWriter class B. Repeat B from above but use the BufferedReader class.

  • Discrete Structures class. An ordered triple of positive integers (a,b,c) is called a Pythagorean Triple if...

    Discrete Structures class. An ordered triple of positive integers (a,b,c) is called a Pythagorean Triple if a^2 + b^2 = c^2. Prove that if m & n are pos int.... 2) (10 pts) An ordered triple of positive integers (a, b, c) is called a Pythagorean Triple if a² + b2 = c2. Prove that if m and n are positive integers with m > n, then (m? – nº, 2mn, m² + n°) is a Pythagorean triple. Use this...

  • Write a C program that reads a list of positive integers from a file named "input.txt."...

    Write a C program that reads a list of positive integers from a file named "input.txt." and count number of odd integers and even integers and prints the results to another file called "results.txt". Please submit both the input and results files along with the c program.

  • 1. Write a program that prompts the user to enter three integers and display the integers...

    1. Write a program that prompts the user to enter three integers and display the integers in non-decreasing order. You can assume that all numbers are valid. For example: Input Result 140 -5 10 Enter a number: Enter a number: Enter a number: -5, 10, 140 import java.util.Scanner; public class Lab01 { public static void main(String[] args) { Scanner input = new Scanner(System.in);    } } ---------------------------------------------------------------------------------------------------------------------------- 2. Write a program that repeatedly prompts the user for integer values from...

  • Problem 2. In the Subset-Sum problem the input consists of a set of positive integers X...

    Problem 2. In the Subset-Sum problem the input consists of a set of positive integers X = {x1, . . . , xn}, and some integer k. The answer is YES if and only if there exists some subset of X that sums to k. In the Bipartition problem the input consists of a set of positive integers Y = {y1, . . . , yn}. The answer is YES if and only if there exists some subset of X...

  • 2. In this problem, the domain of discourse is the set of positive integers: {1, 2,...

    2. In this problem, the domain of discourse is the set of positive integers: {1, 2, 3, ...}. Which statements are true? If an existential statement is true, give an example. If a universal statement is false, give a counterexample. (a) ∀x(x 2 − 1 > 0) (b) ∀x(x 2 − x > 0) (c) ∃x(x 3 = 8) (d) ∃x(x + 1 = 0)

  • 2. Write a Marie program that accepts two positive (inputs) two integers and outputs the sum...

    2. Write a Marie program that accepts two positive (inputs) two integers and outputs the sum of both of the integers and all the numbers in between Write a Marie program that determines the largest of a series of positive integers provided by a user. The user will enter a -1 when she is finished. Up to 10 numbers will be provided by the user. Write a Marie program that accepts two positive integers, multiples them by repeated addition, and...

  • Please use Python to solve this problem: Write a loop that reads positive integers from standard...

    Please use Python to solve this problem: Write a loop that reads positive integers from standard input and that terminates when it reads an integer that is not positive. After the loop terminates, it prints out, on a single line and separated by a single space, the sum of all the even integers read and the sum of all the odd integers read.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT