To use this website fully, you first need to accept the use of cookies. By agreeing to the use of cookies you consent to the use of functional cookies. For more information read this page.

Official ZPE/YASS documentationis_prime_number

is_prime_number (number value) ⇒ boolean

Checks if a number, value, is a prime number.

First available: Version 1.8.2

Notes

An example below use the is_prime_number function to calculate whether the first 100 numbers are prime or not.

YASS
for ($i = 0 to 100)
  print($i & " : " & is_prime_number($i) ? "Yes" : "No")
end for
  

The example below finds the first 100 prime numbers and uses a list to add the numbers to.

YASS
$l = []
$i = 2
while (list_get_length($l) < 100)
  $x = $i & " : " & is_prime_number($i) ? list_add_element($l, $i) : do_nothing()
  $i++
end while

print($l)
  
Comments

There are no comments on this page.

New comment
Reply
Provide feedback on this page
Comments are sent via email to me.