<!DOCTYPE stack PUBLIC "-//Apple, Inc.//DTD stack V 2.0//EN" "" >
<stack>
<name>in</name>
<id>-1</id>
<cardCount>1</cardCount>
<cardID>3631</cardID>
<listID>2129</listID>
<cantModify><false /></cantModify>
<cantDelete><false /></cantDelete>
<cantAbort><false /></cantAbort>
<cardSize>
<width>416</width>
<height>240</height>
</cardSize>
<script>function binaryAND x,yput baseconvert(x,10,2) into bxput baseconvert(y,10,2) into byrepeat while (the number of chars in bx) < (the number of chars in by)put "0" before bxend repeatrepeat while (the number of chars in by) < (the number of chars in bx)put "0" before byend repeatput "" into bzrepeat with xx = 1 to (the number of chars in by)put char xx of bx into c1put char xx of by into c2put ((c1 = 1) AND (c2 = 1)) into boolif bool then put "1" after bzif not bool then put "0" after bzend repeatreturn baseconvert(bz,2,10)end binaryANDfunction binaryOR x,yput baseconvert(x,10,2) into bxput baseconvert(y,10,2) into byrepeat while (the number of chars in bx) < (the number of chars in by)put "0" before bxend repeatrepeat while (the number of chars in by) < (the number of chars in bx)put "0" before byend repeatput "" into bzrepeat with xx = 1 to (the number of chars in by)put char xx of bx into c1put char xx of by into c2put ((c1 = 1) OR (c2 = 1)) into boolif bool then put "1" after bzif not bool then put "0" after bzend repeatreturn baseconvert(bz,2,10)end binaryORfunction binaryXOR x,yput baseconvert(x,10,2) into bxput baseconvert(y,10,2) into byrepeat while (the number of chars in bx) < (the number of chars in by)put "0" before bxend repeatrepeat while (the number of chars in by) < (the number of chars in bx)put "0" before byend repeatput "" into bzrepeat with xx = 1 to (the number of chars in by)put char xx of bx into c1put char xx of by into c2put ((c1 = 1) OR (c2 = 1)) into boolif ((c1 = 1) AND (c2 = 1)) then put false into boolif bool then put "1" after bzif not bool then put "0" after bzend repeatreturn baseconvert(bz,2,10)end binaryXORfunction binaryNOT xput baseconvert(x,10,2) into bxput "" into bzrepeat with xx = 1 to (the number of chars in bx)put char xx of bx into c1if c1 = 0 then put "1" after bzif c1 = 1 then put "0" after bzend repeatreturn baseconvert(bz,2,10)end binaryNOTfunction isPrime xif x < 2 then return "neither"if intgr(x) <> x then return "neither"if (x > 6) and (last char of x is in "024685") then return false -- cheating shortcutif (x < 7) then return item x of "neither,true,true,false,true,false,true" -- and anotherput true into bolrepeat with xx = 2 to intgr(sqrt(x))if (x/xx) = intgr(x/xx) then put false into bolend repeatreturn bolend isPrimefunction isComposite xif x < 2 then return "neither"if intgr(x) <> x then return "neither"return (not (isprime(x)))end isCompositefunction isPerfect xput empty into factorListif x < 1 then return "neither"if intgr(x) <> x then return "neither"if comma & x & comma is in ",6,28,496,8128,33550336,8589869056,137438691328,2305843008139952128," then return true -- cheating shortcutif x < 100000000 then return false -- and anotherif (factorSum(x)-x) = x then return truereturn falseend isPerfectfunction isAbundant xput empty into factorListif x < 1 then return "neither"if intgr(x) <> x then return "neither"if comma & x & comma is in ",6,28,496,8128,33550336,8589869056,137438691328,2305843008139952128," then return falsereturn (factorSum(x)-x) > xend isAbundantfunction isDeficient xput empty into factorListif x < 1 then return "neither"if intgr(x) <> x then return "neither"if comma & x & comma is in ",6,28,496,8128,33550336,8589869056,137438691328,2305843008139952128," then return falsereturn (factorSum(x)-x) < xend isDeficientfunction isHappy xif x < 0 then return "neither"if intgr(x) <> x then return "neither"put 0 into arepeat with i = 1 to (the number of chars in x)add (char i of x)^3 to aend repeatreturn (a = x)end isHappyfunction isPalindromic xput x into n1put empty into n2repeat with x = 1 to (the number of chars in n1)put char x of n1 before n2end repeatreturn (n1 = n2)end isPalindromicfunction isTriangular xreturn (sqrt((8*x)+1) = intgr(sqrt((8*x)+1)))end isTriangularfunction isSquare xreturn (sqrt(x) = intgr(sqrt(x)))end isSquarefunction isEven xreturn (x/2 = intgr(x/2))end isEvenfunction isOdd xreturn not isEven(x)end isOddfunction isPositive xreturn (x > 0)end isPositivefunction isNegative xreturn (x < 0)end isNegativefunction thePerfectness xif isAbundant(x) then return "1"if isDeficient(x) then return "-1"if isPerfect(x) then return "0"end thePerfectnessfunction thePolarity xreturn sgn(x)end thePolarity</script>