Examples
Algorithm Showcase
Explore classic algorithms written in PseudoFlow pseudocode. Copy and paste them directly into the app to see the flowcharts.
Iteration
Factorial
Calculate the factorial of a number using a for loop (repeat).
declare n, fact
print "Enter n:"
read n
fact = 1
repeat (for i = 1 until n steps 1)
fact = fact * i
endrepeat
print "Factorial: " + fact
Conditionals
Maximum of N Numbers
Find the largest number among N inputs using if-else comparisons.
declare n, max
print "How many numbers?"
read n
declare num
repeat (for i = 1 until n steps 1)
print "Enter number:"
read num
if (i == 1)
max = num
else
if (num > max)
max = num
endif
endif
endrepeat
print "Maximum: " + max
While Loop
Sum of Digits
Compute the sum of the digits of an integer using a while loop.
declare sum = 0, num, digit
print "Enter a number:"
read num
while (num > 0)
digit = num % 10
sum = sum + digit
num = (num - digit) / 10
endwhile
print "Sum of digits: " + sum
Conditionals + Iteration
Prime Checker
Determine whether a given number is prime using a flag and a loop.
declare n, isPrime
print "Enter a number:"
read n
isPrime = 1
if (n <= 1)
isPrime = 0
else
repeat (for i = 2 until n / 2 steps 1)
if (n % i == 0)
isPrime = 0
endif
endrepeat
endif
if (isPrime == 1)
print n + " is prime"
else
print n + " is not prime"
endif
Switch Case
Day of Week
Convert a numeric day into its name using switch-case with exact value matching.
declare day
print "Enter day number (1-7):"
read day
switch (day)
case 1:
print "Monday"
endcase
case 2:
print "Tuesday"
endcase
case 3:
print "Wednesday"
endcase
case 4:
print "Thursday"
endcase
case 5:
print "Friday"
endcase
case 6:
print "Saturday"
endcase
case 7:
print "Sunday"
endcase
endswitch
Arrays
Array Sum
Sum all elements of an array using a repeat loop and array indexing.
declare arr = [4, 7, 2, 9, 3]
declare sum = 0
repeat (for i = 0 until arr.length - 1 steps 1)
sum = sum + arr[i]
endrepeat
print "Array sum: " + sum