Skip to content
EspañolWorkspace →

Solved math exercises in PSeInt

12 examples

How it works

Many pseudocode exercises are maths problems: averages, areas, prime numbers, divisors. The operators are the usual ones (+, -, *, /, ^) plus MOD, which gives the remainder of a division.

MOD solves a surprising number of problems: n MOD 2 = 0 tells whether a number is even, and n MOD d = 0 whether d divides n. Trunc(n / 10) drops the last digit of a number.

For the rest there are ready-made functions: Raiz, Abs, Redon, Trunc, and constants like PI. Combined with a loop, they're enough to find primes, compute the greatest common divisor or add up a number's digits.

Short example

The least you need to see it work. Copy it or open it in the editor.

math.psc · 12 lines
Algoritmo Divisors    Definir n, d Como Entero    Escribir "Type a number:"    Leer n    Escribir Sin Saltar "Divisors of ", n, ": "    Para d <- 1 Hasta n Hacer        Si n MOD d = 0 Entonces            Escribir Sin Saltar d, " "        FinSi    FinPara    Escribir ""FinAlgoritmo

What it prints:

Type a number:User answer: 12Divisors of 12: 1 2 3 4 6 12 
Open it in Codoritmo

Opens in the browser editor, nothing to install.

Solved exercises

Each exercise comes with the full code, its flowchart and a sample run.

  • Temperature Converter

    Converts degrees Celsius to Fahrenheit and Kelvin.

    Beginner
  • Tip Calculator

    Splits a restaurant bill, tip included.

    Beginner
  • Fibonacci Sequence

    Prints the first terms of the Fibonacci sequence.

    Beginner
  • Body Mass Index

    Computes your BMI and classifies it as underweight, normal and so on.

    Intermediate
  • Parking Fee

    Charges every started hour, with a daily maximum.

    Intermediate
  • Prime Numbers

    Finds every prime number up to a limit.

    Intermediate
  • GCD and LCM

    Computes the greatest common divisor and the least common multiple.

    Intermediate
  • Quadratic Equation

    Solves ax² + bx + c = 0, with real or complex roots.

    Intermediate
  • Geometry

    Finds a circle's area and solves a right triangle.

    Intermediate
  • Compound Interest

    Watch your savings grow year by year.

    Intermediate
  • Caesar Cipher

    Encrypts a message by shifting each letter of the alphabet.

    Advanced
  • Base Conversion

    Writes a number in binary and hexadecimal.

    Advanced

In the language reference

The instructions involved, explained one by one.

Other concepts

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.