Babbage problem: Difference between revisions

Content deleted Content added
Steenslag (talk | contribs)
m →‎{{header|REXX}}: corrected a typo, optimized a couple of versions (to just use even numbers).
Line 179: Line 179:
:* &nbsp; what the &nbsp; <big>'''//'''</big> &nbsp; operator is and what it does division remainder
:* &nbsp; what the &nbsp; <big>'''//'''</big> &nbsp; operator is and what it does division remainder
:* &nbsp; what the &nbsp; '''right''' &nbsp; BIF does
:* &nbsp; what the &nbsp; '''right''' &nbsp; BIF does
:* &nbsp; what a &nbsp; '''BIF''' &nbsp is and how it returns a value
:* &nbsp; what a &nbsp; '''BIF''' &nbsp; is and how it returns a value
:* &nbsp; how/when the &nbsp; '''then''' &nbsp; cause gets executed &nbsp; (after an &nbsp; '''if''')
:* &nbsp; how/when the &nbsp; '''then''' &nbsp; cause gets executed &nbsp; (after an &nbsp; '''if''')
:* &nbsp; explain how/why an &nbsp; '''end''' &nbsp; statement is needed for the '''do''' loop
:* &nbsp; explain how/why an &nbsp; '''end''' &nbsp; 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=1 by 1 /*start J at unity, increment by 1.*/
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=1 by 1 /*start J at unity, increment by 1.*/
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*/