PSeInt MOD operator: the remainder of a division
Gives the remainder (what's left over) of a whole-number division. Very handy to check whether a number is even (n MOD 2 = 0) or a multiple of another.
- Group:
- Algebraic
- Template
MOD
Opens the editor with this example loaded. Run it step by step and watch the flowchart.
Worked example
A complete algorithm, ready to copy and run.
Algoritmo Example Escribir 17 MOD 5FinAlgoritmoOutput
Shows: 2 (5 goes into 17 three times with 2 left over)
This is what the console shows when the example runs.
2Good to know
Instead of MOD you can write %. The symbol works in every profile; the word MOD works in profiles that allow word operators, like the default one.
Some details depend on your school's profile. See the language profiles.
In a flowchart
This is how it appears in a flowchart, with the same shapes Codoritmo draws.
Template
The general form. Replace what's inside < > with your own data.
MODExamples that use it
Programs from the example library where it appears, from the simplest to the most complete.
Parking Fee
Charges every started hour, with a daily maximum.
IntermediatePrime Numbers
Finds every prime number up to a limit.
IntermediateGCD and LCM
Computes the greatest common divisor and the least common multiple.
IntermediateCaesar Cipher
Encrypts a message by shifting each letter of the alphabet.
AdvancedBase Conversion
Writes a number in binary and hexadecimal.
AdvancedATM
Checks your PIN and lets you check, deposit and withdraw money.
Advanced
More algebraic
Codoritmo is an independent, open-source project inspired by PSeInt and compatible with its syntax. It is not affiliated with the PSeInt project. Official PSeInt website.