- Joined
- Oct 31, 2010
- Messages
- 238
Okay, someone review this function for me! (First time coding something by myself in JASS/vJASS without other people's help!)
And please tell me whether is it in JASS or vJASS. I don't see the difference between them.
And please tell me whether is it in JASS or vJASS. I don't see the difference between them.
JASS:
scope CheckPrime
globals
integer int //Constant, does not change at ALL until checked = false
integer int_2 //Changes
boolean checked = false
boolean isPrime
endglobals
function CheckPrime takes integer number returns boolean
if(number<=1) then
call BJDebugMsg("Please enter a value larger than 1!")
set isPrime = false
else
////////////////////////////////////////////
if(checked == false) then
set checked = true
set int = number
endif
////////////////////////////////////////////
set int_2 = number
if (ModuloInteger(int, int_2) == 0) and (int != int_2) then //Divisible, and int not equal to int_2, NOT PRIME
set int_2 = 0
endif
if (int_2 == 0) then //If Its not a Prime Number
call BJDebugMsg(I2S(int)+" is NOT Prime!")
set checked = false
set isPrime = false
else //Checking...
if(int_2-1 == 1) then //If the next number becomes 1, and so far it still prime, then the number IS PRIME!
call BJDebugMsg(I2S(int)+" IS Prime!")
set checked = false
set isPrime = true
else
set int_2 = int_2 - 1
call CheckPrime(int_2)
endif
endif
endif
if(isPrime == true) then
return true
else
return false
endif
endfunction
endscope
Last edited: