How do I get Prime numbers 1-100

How do I get prime numbers 1-100 ?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    Hi Please check out this solution,

    As according to the definition of prime number that it should be divisible by itself creates the logic. Bellow is the code

    a!localVariables(
         local!listOfNumbers: enumerate(ri!number),
         a!forEach(
             local!listOfNumbers,
             {
                 a!localVariables(
                       local!currentItem: fv!item,
                       if(
                          count(
                          a!forEach(
                                local!listOfNumbers,
                                if(mod(local!currentItem, fv!item) = 0, 1, {})
                                )
                           ) > 2,
                           {},
                           fv!item
                         )
                    )
              }

          ) 

    )

Reply
  • 0
    Certified Senior Developer

    Hi Please check out this solution,

    As according to the definition of prime number that it should be divisible by itself creates the logic. Bellow is the code

    a!localVariables(
         local!listOfNumbers: enumerate(ri!number),
         a!forEach(
             local!listOfNumbers,
             {
                 a!localVariables(
                       local!currentItem: fv!item,
                       if(
                          count(
                          a!forEach(
                                local!listOfNumbers,
                                if(mod(local!currentItem, fv!item) = 0, 1, {})
                                )
                           ) > 2,
                           {},
                           fv!item
                         )
                    )
              }

          ) 

    )

Children
No Data