Skip to content

Instantly share code, notes, and snippets.

@rofr
Created May 11, 2012 15:01
Show Gist options
  • Save rofr/2660299 to your computer and use it in GitHub Desktop.
Save rofr/2660299 to your computer and use it in GitHub Desktop.
Xsharp prime number tester
<xsharp>
<set var='isPrime'><true/></set>
<set var='i'><int>3</int></set>
<set var='root'>
<call class='Math' method='Sqrt'>
<get var='numberToTest'/>
</call>
</set>
<while>
<and>
<get var='isPrime'/>
<less-than-or-equal><get var='i'/><get var='numberToTest'/></less-than-or-equal>
</and>
<if>
<equals><int>0</int><mod><get var='numberToTest'/><get var='i'/></mod></equals>
<set var='isPrime'><false/></set>
</if>
<set var='i'><add><get var='i'/><int>2</int></add></set>
</while>
<call class='System.Console' method='Write'>
<get var='numberToTest'/>
</call>
<call class='System.Console' method='WriteLine'>
<if>
<get var='isPrime'/>
<string> is prime</string>
<else>
<string> is not prime</string>
</else>
</if>
</call>
</xsharp>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment