I cannot spot why the second question is always marked as correct. Hoping for some help...

DOCUMENT();

loadMacros(

"PGstandard.pl",

"MathObjects.pl",

"PGchoicemacros.pl",

"algebraMacros.pl",

"PGcourse.pl","PGauxiliaryFunctions.pl"

);

TEXT(beginproblem());

$showPartialCorrectAnswers = 0;

#

# In this problem we determine the intersection of two subgroups of

# Z_n and find an element NOT in the intersection

#

@set = (2, 3, 5, 7, 11, 13, 17, 19);

#

# pick three distinct primes from the list

#

$r1 = random(0,7,1);

$r2 = random(0,7,1);

while($r1 == $r2){

$r2 = random(0,7,1);

}

$r3 = random(0,7,1);

while($r3 == $r1 || $r3 == $r2){

$r3 = random(0,7,1);

}

$p1 = $set[$r1];

$p2 = $set[$r2];

$p3 = $set[$r3];

$n = $p1 * $p2 * $p3;

$p23 = $p2 * $p3;

$rx = random(1,25,1);

while( gcd($rx, $p23) > 1 ) {

$rx = random(1,25,1);

}

$x = $rx * $p1;

$p13 = $p1 * $p3;

$ry = random(1,25,1);

while( gcd($ry, $p13) > 1 ) {

$ry = random(1,25,1);

}

$y = $ry * $p2;

$p12 = $p1 * $p2;

$answer1 = Compute( $p3 );

# example of an element of Z/$n not in <$x> \intersect <$y>

$answer2 = Compute( 1 );

BEGIN_TEXT

(a) Find the order of the subgroup \(\langle $x \rangle \cap \langle $y \rangle\) of \( \{ cyclic( $n ) \} \) $BR $BR

\{ ans_rule(10) \} $BR $BR

(b) Write down one element of \( \{ cyclic( $n ) \} \) not in \(\langle $x \rangle \cap \langle $y \rangle\). $BR $BR

\{ ans_rule(10) \}

END_TEXT

ANS( $answer1->cmp );

#

# custom answer check for second part:

# input is correct <==> gcd( student's input, $p12) = 1

ANS( $answer2->cmp(checker=> sub

{

my( $student, $correct, $ansHash ) = @_;

return (gcd( $student, $p12 ) == 1 ) ? 1 : 0;

}

) );

ENDDOCUMENT();