R=$graad
!if $negatief=1
    !if $taal=nl
	hint=zie de help-pagina
	nivo_title=Alle rekenregels<br> (nu ook met negatieve getallen)
    !else
	nivo_title=Calculating: Priority rules <br> (also with negative numbers)
	hint=look into the help-pages
    !endif
    
    !for n=1 to $aantal_sommen 
	!if $graad=0
	    R=$n
	!endif    
        !if $R=1	
	    a=!randitem -2,-3,-4,-5,-6,-7,-8,-9,-10,2,3,4,5,6,7,8,9,10
	    aa=!randint 10,40
	    c=!randitem 2,3,4,5,6,7,8,9,10
	    GOED$n=$[$a*$aa]
	    b=$[-1*$c + $(GOED$n)/$a]
	    somtekst$n=$a\cdot($b+$c)\,\,\,=\,\,\,
	    extra$n=$a \cdot $[$b + $c]\,\,\,=\,\,\,
	!endif
	!if $R=2
	    a=!randitem -2,-3,-4,-5,-6,-7,-8,-9,-10
	    aa=!randitem 2,3,4,5,6,7,8,9,10
	    GOED$n=$[$a*$aa]
	    c=!randint 10,100
	    b=$[$c + $(GOED$n)/$a]
	    somtekst$n=$a\cdot($b-$c)\,\,\,=\,\,\,
	    extra$n=$a \cdot $[$b - $c]\,\,\,=\,\,\,
	!endif
	!if $R=3 
	    a=!randitem 2,3,4,5,6,7,8,9,10,-2,-3,-4,-5,-6,-7,-8,-9,-10
	    aa=!randitem 2,3,4,5,6,7,8,9,10
	    GOED$n=$[$a*$aa]
	    c=!randitem 2,3,4,5,6,7,8,9,10
	    b=$[$c*$(GOED$n)/$a]
	    somtekst$n= $b \div $c \cdot $a \,\,\,=\,\,\,
	    extra$n=$[$b*$a] \div $c \,\,\,=\,\,\,
	!endif
	!if $R=4 
	    bc=!randitem 2,3,4,5,6,7,8,9,10,-2,-3,-4,-5,-6,-7,-8,-9,-10
	    bc=$[2*$bc]
	    c=!randitem 2,3,4,5,6,7,8,9,10,-2,-3,-4,-5,-6,-7,-8,-9,-10
	    b=$[$bc*$c]
	    a=!randitem 1,2,3,4,5,6,7,8,9,10,-1,-2,-3,-4,-5,-6,-7,-8,-9,-10
	    d=!randitem 4,5,6,7,8,9,10,11,12,13,14,15
	    GOED$n=!exec pari ($a+$d)*($b/$c)
	    somtekst$n=($a+$d) \cdot $b \div $c\,\,\,=\,\,\,
	    extra$n=$[$a+$d] \cdot $b \div $c = $[($a+$d)*$b] \div $c \,=
	!endif
	!if $R=5
	    ac=!randitem 2,3,4,5,6,7,8,9,10,-2,-3,-4,-5,-6,-7,-8,-9,-10
	    ac=$[2*$ac]
	    c=!randitem 2,3,4,5,6,7,8,9,10,-2,-3,-4,-5,-6,-7,-8,-9,-10
	    a=$[$c*$ac]
	    b=!randint 3,49
	    GOED$n=!exec pari ($a)/($c)
	    somtekst$n=$a \div $b \cdot $b \div $c\,\,\,=\,\,\,
	    extra$n=\frac{$a}{$b} \cdot \frac{$b}{$c}= $[$a/$b] \cdot $[$b/$c] \,=
	!endif
	!if $R=6
    	    a=!randitem 1,2,3,4,5
	    b=!randitem 6,7,8,9,-6,-7,-8,-9

	    c=!randitem 4,5,6,7,8,9,-4,-5,-6,-7,-8,-9
	    d=!randitem 1,2,3
	    somtekst$n=($b-$a)\cdot($c-$d)\,\,\,=\,\,\,
	    GOED$n=$[($b-$a)*($c-$d)]
	    extra$n=$[$b - $a] \cdot $[$c - $d] \,\,\,=\,\,\,
	!endif
	!if $R>6
	    bc=!randitem 1,2,3,4,5,-2,-3,-4,-5
	    bc=$[2*$bc]
	    c=!randitem 2,3,4,5,-2,-3,-4,-5
            b=$[$bc*$c]
    	    ad=!randitem 1,2,3,4,5,-1,-2,-3,-4,-5
    	    ad=$[2*$ad]
    	    d=!randitem 2,3,4,5,-2,-3,-4,-5
    	    a=$[$ad*$c]
    	    GOED$n=!exec pari ($a/$d)*($b/$c)
    	    somtekst$n=$a \div $d \cdot $b \div $c \,\,\,=\,\,\,
	    extra$n=\frac{$a}{$d} \cdot \frac{$b}{$c}\,\,\,=\,\,\,
	!endif
    !next n
 !exit    
!endif
!if $negatief=0  
    !if $taal=nl
	nivo_title=Alle rekenregels<br>alleen positieve getallen 
    !else
	nivo_title=Priority rules<br>(only positive numbers) 
    !endif
    !for n=1 to $aantal_sommen 
	!if $graad=0
	    R=$n
	!endif    
        !if $R=1	
	    a=!randitem 2,3,4,5,6,7,8,9,10
	    aa=!randint 10,40
	    c=!randitem 2,3,4,5,6,7,8,9,10
	    GOED$n=$[$a*$aa]
	    b=$[-1*$c + $(GOED$n)/$a]
	    somtekst$n=$a \cdot ($b+$c)\,\,\,=\,\,\,
	    extra$n=$a \cdot $[$b + $c]\,\,\,=\,\,\,
	!endif
	!if $R=2
	    a=!randint 2,10
	    aa=!randint 2,10
	    GOED$n=$[$a*$aa]
	    c=!randint 10,100
	    b=$[$c + $(GOED$n)/$a]
	    somtekst$n=$a \cdot ($b-$c)\,\,\,=\,\,\,
	    extra$n=$a \cdot $[$b - $c]\,\,\,=\,\,\,	    
	!endif
	!if $R=3 
	    a=!randitem 2,3,4,5,6,7,8,9,10
	    aa=!randitem 2,3,4,5,6,7,8,9,10
	    GOED$n=$[$a*$aa]
	    c=!randitem 2,3,4,5,6,7,8,9,10
	    b=$[$c*$(GOED$n)/$a]
	    somtekst$n= $b \div $c \cdot $a \,\,\,=\,\,\,
	    extra$n=$[$b*$a] \div $c \,\,\,=\,\,\,
	!endif
	!if $R=4 
	    bc=!randitem 2,3,4,5,6,7,8,9,10
	    bc=$[2*$bc]
	    c=!randitem 2,3,4,5,6,7,8,9,10
	    b=$[$bc*$c]
	    a=!randitem 1,2,3,4,5,6,7,8,9,10
	    d=!randitem 4,5,6,7,8,9,10,11,12,13,14,15
	    GOED$n=!exec pari ($a+$d)*($b/$c)
	    somtekst$n=($a+$d) \cdot $b \div $c\,\,\,=\,\,\,
	    extra$n=$[$a + $d] \cdot $b \div $c = $[($a + $d)*$b] \div $c \,=\,\,
	!endif
	!if $R=5
	    ac=!randitem 2,3,4,5,6,7,8,9,10
	    ac=$[2*$ac]
	    c=!randitem 2,3,4,5,6,7,8,9,10
	    a=$[$c*$ac]
	    b=!randint 3,49
	    GOED$n=!exec pari ($a)/($c)
	    somtekst$n=$a \div $b \cdot $b \div $c\,\,\,=\,\,\,
	    extra$n=\frac{$a}{$b} \cdot \frac{$b}{$c} \,\,\,=\,\,\,
	!endif
	!if $R=6
    	    a=!randitem 1,2,3,4,5
	    b=!randitem 6,7,8,9
	    c=!randitem 6,7,8,9
	    d=!randitem 1,2,3,4,5
	    somtekst$n=($b-$a) \cdot ($c-$d)\,\,\,=\,\,\,
	    GOED$n=$[($b-$a)*($c-$d)]
	    extra$n=$[$b - $a] \cdot $[$c - $d]\,\,\,=\,\,\,
	!endif
	!if $R>6
	    bc=!randitem 1,2,3,4,5
	    bc=$[2*$bc]
	    c=!randitem 2,3,4,5
            b=$[$bc*$c]
    	    ad=!randitem 1,2,3,4,5
    	    ad=$[2*$ad]
    	    d=!randitem 2,3,4,5
    	    a=$[$ad*$c]
    	    GOED$n=!exec pari ($a/$d)*($b/$c)
    	    somtekst$n=$a \div $d \cdot $b \div $c\,\,\,=\,\,\,
	    extra$n=\frac{$a}{$d} \cdot \frac{$b}{$c} \,\,\,=\,\,\,
	!endif
    !next n
!endif    

