Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import std.range : iota;
- import std.math : sqrt;
- bool isPrime(int n)()
- {
- static if(n==2)
- {
- return true;
- }
- else static if(n%2==0)
- {
- return false;
- }
- else
- {
- static foreach(int i;iota(3,cast(int)sqrt(cast(real)n),2))
- {
- if(n%i==0)
- {
- return false;
- }
- }
- return true;
- }
- }
- enum myNum=1000000007;
- pragma(msg,"myNum is:");
- pragma(msg,myNum);
- pragma(msg,"is myNum prime?");
- pragma(msg,isPrime!myNum);
- static assert(0,"this program isn't supposed to finish compiling");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement