How do I get Prime numbers 1-100

How do I get prime numbers 1-100 ?

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Senior Developer
    in reply to ajhick

    I would like to tweak the logic as the below code does not exclude 1 which is not a prime number since 1 has less than one factor, A prime number needs to have exactly two factors.

    sum(mod(ri!number, enumerate(ri!number) + 1) = 0) <= 2

    Do this instead! 

    length(
      wherecontains(true, mod(ri!number, enumerate(ri!number) + 1) = 0)
    ) = 2

    OR

    sum(mod(ri!number, enumerate(ri!number) + 1) = 0) = 2

    Feel free to correct me if I am wrong.