Arithmetic/Integer: Difference between revisions
Content deleted Content added
J: simplify |
added Inform 7 solution |
||
Line 650: | Line 650: | ||
==={{header|Unicon}}=== |
==={{header|Unicon}}=== |
||
This Icon solution works in Unicon. |
This Icon solution works in Unicon. |
||
=={{header|Inform 7}}== |
|||
<lang inform7>Enter Two Numbers is a room. |
|||
Numerically entering is an action applying to one number. Understand "[number]" as numerically entering. |
|||
The first number is a number that varies. |
|||
After numerically entering for the first time: |
|||
now the first number is the number understood. |
|||
After numerically entering for the second time: |
|||
let A be the first number; |
|||
let B be the number understood; |
|||
say "[A] + [B] = [A + B]."; [operator syntax] |
|||
say "[A] - [B] = [A minus B]."; [English syntax] |
|||
let P be given by P = A * B where P is a number; [inline equation] |
|||
say "[A] * [B] = [P]."; |
|||
let Q be given by the Division Formula; [named equation] |
|||
say "[A] / [B] = [Q]."; |
|||
say "[A] mod [B] = [remainder after dividing A by B]."; |
|||
end the story. |
|||
Equation - Division Formula |
|||
Q = A / B |
|||
where Q is a number, A is a number, and B is a number.</lang> |
|||
This solution shows four syntaxes: mathematical operators, English operators, inline equations, and named equations. Division rounds toward zero, and the remainder has the same sign as the quotient. |
|||
=={{header|J}}== |
=={{header|J}}== |