Babbage problem: Difference between revisions
Content deleted Content added
→{{header|Ruby}}: Added Ruby |
m →{{header|REXX}}: corrected a typo, optimized a couple of versions (to just use even numbers). |
||
Line 179: | Line 179: | ||
:* what the <big>'''//'''</big> operator is and what it does division remainder |
:* what the <big>'''//'''</big> operator is and what it does division remainder |
||
:* what the '''right''' BIF does |
:* what the '''right''' BIF does |
||
:* what a '''BIF'''   is and how it returns a value |
:* what a '''BIF''' is and how it returns a value |
||
:* how/when the '''then''' cause gets executed (after an '''if''') |
:* how/when the '''then''' cause gets executed (after an '''if''') |
||
:* explain how/why an '''end''' statement is needed for the '''do''' loop |
:* explain how/why an '''end''' statement is needed for the '''do''' loop |
||
Line 187: | Line 187: | ||
<lang rexx>/*REXX program finds the lowest (positive) integer whose square ends in 269,696. */ |
<lang rexx>/*REXX program finds the lowest (positive) integer whose square ends in 269,696. */ |
||
/*operator * is multiplication. */ |
/*operator * is multiplication. */ |
||
do j= |
do j=2 by 2 /*start J at two, increment by two. */ |
||
if right(j*j, 6)==269696 then leave /*is six right-most digits our target? */ |
if right(j*j, 6)==269696 then leave /*is six right-most digits our target? */ |
||
end /*this signifies the end of the DO loop*/ |
end /*this signifies the end of the DO loop*/ |
||
Line 200: | Line 200: | ||
<lang rexx>/*REXX program finds the lowest (positive) integer whose square ends in 269,696. */ |
<lang rexx>/*REXX program finds the lowest (positive) integer whose square ends in 269,696. */ |
||
/*operator // is division remainder.*/ |
/*operator // is division remainder.*/ |
||
do j= |
do j=2 by 2 /*start J at two, increment by two. */ |
||
if j*j // 1000000 == 269696 then leave /*is square mod 1-million our target ? */ |
if j*j // 1000000 == 269696 then leave /*is square mod 1-million our target ? */ |
||
end /*this signifies the end of the DO loop*/ |
end /*this signifies the end of the DO loop*/ |