<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Is there any rule to print all prime numbers within a range and range should pass through rule input ?</title><link>https://community.appian.com/discussions/f/rules/34458/is-there-any-rule-to-print-all-prime-numbers-within-a-range-and-range-should-pass-through-rule-input</link><description>rule!Is primenumber{} 
 
 how to implement it correctly when I want to get it in a specific range ?</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Is there any rule to print all prime numbers within a range and range should pass through rule input ?</title><link>https://community.appian.com/thread/131991?ContentTypeID=1</link><pubDate>Wed, 27 Mar 2024 21:30:05 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:2857f8a8-2108-4f6a-ac94-d38e4b36eaa6</guid><dc:creator>David Jimenez </dc:creator><description>&lt;p&gt;Which error are you receiving? As &lt;a href="/members/mikes0011"&gt;Mike Schmitt&lt;/a&gt;&amp;nbsp; said,, the code works fine and you only need to add two input variables in your expression rule (lower and upper)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is there any rule to print all prime numbers within a range and range should pass through rule input ?</title><link>https://community.appian.com/thread/131989?ContentTypeID=1</link><pubDate>Wed, 27 Mar 2024 20:13:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6a90b8d9-8e04-4111-bac5-d6ca98ccce7e</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;just for the fun of it:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!localVariables(
  /*
  local!lower: enumerate(ri!lower) + 1,
  local!upper: enumerate(ri!upper) + 1,
  local!value: remove(local!upper, wherecontains(local!lower, local!upper)),
  (the above can just use &amp;quot;difference()&amp;quot; also, though it&amp;#39;s really not necessary either way)
  */
  
  local!betterArray: enumerate(ri!upper - ri!lower) + (1 + ri!lower),

  local!count: a!forEach(
    items: local!betterArray,
    expression: sum(mod(fv!item, enumerate(fv!item) + 1) = 0) &amp;lt;= 2
  ),

  index(
    local!betterArray,
    /*wherecontains(true, local!count)*/
    where(local!count)
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is there any rule to print all prime numbers within a range and range should pass through rule input ?</title><link>https://community.appian.com/thread/131987?ContentTypeID=1</link><pubDate>Wed, 27 Mar 2024 19:59:30 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:bb48e416-8943-4a90-ad8a-3db966350daf</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;I just tried the sample code posted and it works fine for me.&amp;nbsp; What are you trying, exactly, and what result are you getting, to make you think it isn&amp;#39;t working?&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/15/pastedimage1711569915006v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is there any rule to print all prime numbers within a range and range should pass through rule input ?</title><link>https://community.appian.com/thread/131985?ContentTypeID=1</link><pubDate>Wed, 27 Mar 2024 19:34:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a3be42b3-8bf4-4221-931b-49e2d869ef11</guid><dc:creator>adityap0026</dc:creator><description>&lt;p&gt;not working&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is there any rule to print all prime numbers within a range and range should pass through rule input ?</title><link>https://community.appian.com/thread/131764?ContentTypeID=1</link><pubDate>Sun, 24 Mar 2024 23:32:37 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:99b21f70-0702-464b-82da-cd3154e75dd7</guid><dc:creator>David Jimenez </dc:creator><description>&lt;p&gt;Use this, where lower and uppper are the limits of the range you want to work with.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!lower: enumerate(ri!lower) + 1,
  local!upper: enumerate(ri!upper) + 1,
  local!value: remove(local!upper, wherecontains(local!lower, local!upper)),
  

  local!count: a!forEach(
    items: local!value,
    expression: sum(mod(fv!item, enumerate(fv!item) + 1) = 0) &amp;lt;= 2
  ),
 
  index(local!value, wherecontains(true, local!count))
  
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>