Arithmetic, DIV and MOD · חישוב אריתמטי, DIV ו-MOD
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · עמוד זה דורש דפדפן עדכני (תומך ב-SharedArrayBuffer). אנא עדכן את Chrome, Edge, Firefox או Safari לגרסה העדכנית ביותר.
English
Arithmetic operators
- Pseudocode uses
+-*/and^for the usual maths. /gives a real answer (with a decimal point).
עברית
算术运算符
- פסאודוקוד משתמש ב-
+-*/ו-^עבור המתמטיקה המקובלת. /נותן תשובה מציאותית (עם נקודה עשרונית).
OUTPUT 6 + 2 // → 8
OUTPUT 6 * 2 // → 12
OUTPUT 7 / 2 // → 3.5
English
^ raises to a power
^means "to the power of".2 ^ 10is 2 multiplied by itself ten times, which is1024.- The syllabus lists it beside
+,-,*and/.
עברית
^ מעלה לחזקה
^פירושו "לחזקה של".2 ^ 10הוא 2 כפול בעצמו עשר פעמים, שזהו1024.- תוכנית הלימודים מציגה אותה לצד
+,-,*ו-/.
OUTPUT 2 ^ 10 // → 1024
English
DIV: whole-number division
DIV(a, b)divides and throws the remainder away.DIV(17, 5)is3— 5 goes into 17 three whole times.- It is written like a function, with the two numbers in brackets — not between them.
עברית
DIV: חלוקה למספר שלם
DIV(a, b)מחלק ומזרק את השארית.DIV(17, 5)היא3— 5 נכנס ל-17 שלוש פעמים שלמות.- היא כתובה כמו פונקציה, עם שני המספרים בסוגריים — ולא ביניהם.
OUTPUT DIV(17, 5) // → 3
English
MOD: the remainder
MOD(a, b)gives the remainder after dividing.MOD(17, 5)is2. A number is even whenMOD(N, 2) = 0.
עברית
MOD: השארית
MOD(a, b)נותן את השארית לאחר החלוקה.MOD(17, 5)היא2. מספר הוא זוגי כאשרMOD(N, 2) = 0.
OUTPUT MOD(17, 5) // → 2
English
Watch out
DIVandMODwork on whole numbers; plain/gives a decimal.- Together they "undo" a division:
DIV(17, 5) * 5 + MOD(17, 5)=17.
עברית
שימו לב
DIVו-MODעובדים על מספרים שלמים;/רגיל נותן תוצאה עשרונית.- יחד הם "מבטלים" חלוקה:
DIV(17, 5) * 5 + MOD(17, 5)=17.
English
Common mistakes
DIV(a, b)is whole-number division;MOD(a, b)is the remainder. Both are written with brackets.- Use brackets to control the order of arithmetic.
עברית
טעויות נפוצות
DIV(a, b)היא חלוקת שלמים;MOD(a, b)הוא שארית החלוקה. שניהם כתובים בסוגריים.- השתמש בסוגריים כדי לשלוט בסדר ביצוע הפעולות החשבון.
English
Now you try
- Use
+ - * / ^, and the functionsDIV(a, b)/MOD(a, b). - Press Check answer to test it.
עברית
כעת תנסו בעצמכם
- השתמש ב-
+ - * / ^, ובפונקציותDIV(a, b)/MOD(a, b). - לחץ על בדיקת תשובה כדי לבדוק אותה.
Output 6 times 7 (the answer is 42). · הדפס 6 כפול 7 (התשובה היא 42).
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.
Use DIV(20, 3) to output how many whole times 3 goes into 20 (the answer is 6). · השתמש ב-DIV(20, 3) כדי להדפיס כמה פעמים שלמות 3 נכנס לתוך 20 (התשובה היא 6).
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.
Use MOD(23, 5) to output the remainder when 23 is divided by 5 (the answer is 3). · השתמש ב-MOD(23, 5) כדי להדפיס את שארית החלוקה כאשר 23 מחולק ב-5 (התשובה היא 3).
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.
Use ^ to output 2 to the power of 10 (the answer is 1024). · השתמש ב-^ כדי להדפיס את 2 מעורא 10 (התשובה היא 1024).
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.