Created
May 11, 2012 15:01
-
-
Save rofr/2660299 to your computer and use it in GitHub Desktop.
Xsharp prime number tester
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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