Skip to content

Instantly share code, notes, and snippets.

@Yehonal
Created March 19, 2024 08:21
Show Gist options
  • Save Yehonal/cdb167a62e97664d5d4611cc7e914295 to your computer and use it in GitHub Desktop.
Save Yehonal/cdb167a62e97664d5d4611cc7e914295 to your computer and use it in GitHub Desktop.
NestDev - Simple Prime Number Pseudocode (To Complete)
FUNCTION IsPrime(num, primeNumbers)
IF num <= 1 THEN
RETURN FALSE
ENDIF
IF num IN primeNumbers THEN
RETURN TRUE
ENDIF
FOR i FROM 2 TO num - 1 DO
IF num MOD i == 0 THEN
RETURN FALSE
ENDIF
ENDFOR
// If the number is prime, add it to the file
APPEND num TO primeNumbers
WRITE num TO "primeNumbers.txt"
RETURN TRUE
END FUNCTION
MAIN
ARRAY primeNumbers
LOAD “primeNumbers.txt” INTO primeNumbers
INPUT "Enter a number: " TO number
IF IsPrime(number, primeNumbers) THEN
PRINT number, "is a prime number."
ELSE
PRINT number, "is not a prime number."
ENDIF
END MAIN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment