<script type="text/javascript">
function IsPrime(n) {
no = 0;
for(i = 2; i <= n; i++) {
for(d = 2; d < i; d++) {
v = i / d;
if(v != 1 && Math.floor(v)==v) { no = 1; d = i; }
}
if(no != 1) result = i;
no = 0;
}
return (result == n)
}
</script>
<script type="text/javascript">
function IsPrime(n) {
no = 0;
if (i < 2) return true;
for(i = 2; i <= n; i++) {
for(d = 2; d < i; d++) {
v = i / d;
if(v != 1 && Math.floor(v)==v) { no = 1; d = i; }
}
if(no != 1) result = i;
no = 0;
}
return (result == n)
}
</script>
<script type="text/javascript">
function CheckIfPrime(n) {
result = true;
for (i = 2; i <= Math.sqrt(n); i++)
if (!(result = n % i != 0)) break;
return result;
}
</script>
Dim isPrime As Boolean = True
Dim i As Integer = 2
While i <= Math.Sqrt(Currentvalue) AndAlso isPrime
isPrime = Currentvalue Mod i <> 0
i += 1
End While
Title | # Comments | Views | Activity |
---|---|---|---|
Learning regular expressions | 13 | 48 | |
RegEx numeric validation | 2 | 37 | |
vb.net and regular expressions | 8 | 49 | |
Can someone decipher this regex parameter? | 6 | 38 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
10 Experts available now in Live!