Language comparison
The same algorithm, written three ways. The purpose isn’t to learn every language at once — it’s to see that logic is language-independent.
🧩 Count from 1 to 10
1FOR I = 1 TO 102 DISPLAY I3END FOR1<?php2for ($i = 1; $i <= 10; $i++) {3 echo $i . PHP_EOL;4}1for (let i = 1; i <= 10; i++) {2 console.log(i);3}✨ The logic didn’t change. Only the syntax changed.
🧩 Even or odd
1TAKE N2IF N MOD 2 = 0 THEN3 DISPLAY "Even"4ELSE5 DISPLAY "Odd"6END IF1<?php2$n = (int) readline();3if ($n % 2 === 0) {4 echo "Even";5} else {6 echo "Odd";7}1const n = Number(prompt());2if (n % 2 === 0) {3 console.log("Even");4} else {5 console.log("Odd");6}✨ The logic didn’t change. Only the syntax changed.
🧩 Find the largest in a list
1SET NUMS = [4, 17, 9, 23, 8]2SET BIGGEST = NUMS[0]3FOR EACH N IN NUMS4 IF N > BIGGEST THEN5 SET BIGGEST = N6 END IF7END FOR8DISPLAY BIGGEST1<?php2$nums = [4, 17, 9, 23, 8];3$biggest = $nums[0];4foreach ($nums as $n) {5 if ($n > $biggest) {6 $biggest = $n;7 }8}9echo $biggest;1const nums = [4, 17, 9, 23, 8];2let biggest = nums[0];3for (const n of nums) {4 if (n > biggest) {5 biggest = n;6 }7}8console.log(biggest);✨ The logic didn’t change. Only the syntax changed.
🧩 Factorial with a function
1FUNCTION FACT(N)2 SET RESULT = 13 FOR I = 1 TO N4 SET RESULT = RESULT * I5 END FOR6 RETURN RESULT7END FUNCTION8DISPLAY FACT(5)1<?php2function fact($n) {3 $result = 1;4 for ($i = 1; $i <= $n; $i++) {5 $result = $result * $i;6 }7 return $result;8}9echo fact(5);1function fact(n) {2 let result = 1;3 for (let i = 1; i <= n; i++) {4 result = result * i;5 }6 return result;7}8console.log(fact(5));✨ The logic didn’t change. Only the syntax changed.