Level 1Easy function process%QUESTION.NUMBER%(QNo) { ANS= "" SHOW = ""; nwidth=getFontSize()/16*100 nheight=getFontSize()/16*90 a1="" a2="" a3="" b1=""; SHOW="The key to understanding this question is to know that you do not need to check prime numbers larger than "+a1+a2+a3+b1+"

'Why is this?', I hear you ask. Well if you found a prime factor larger than this number then the other factor would have to be smaller and hence it or its prime factors would have already been checked. For example 38 = 2 × 19. The claim here is that we only need check primes up to 6 i.e. 2, 3 and 5. 2 is a factor so we don't need to check further (if we did we'd eventually find 19 was a factor too). On the other hand 43 is prime since we again only need to check primes up to 6 and none of these work as factors.Try it with a few more examples of your own to see how this works in general."; for (var i=5; iYour answer "+document.forms.elements[item].value+" was correct.
"} else {document.forms.elements[item+3].value = "Your answer "+document.forms.elements[item].value+", should have been "+Correct%QUESTION.NUMBER%+"

"+ANS+"
"+SHOW+"
"} document.forms.elements[item+3].value = QuestionText%QUESTION.NUMBER% + document.forms.elements[item+3].value } function question%QUESTION.NUMBER%() { list_of_primes = new Array(); primes = new Array("",2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229) num_prime = Math.ceil(4*Math.random())+6; range = primes[num_prime+1]*primes[num_prime+1]-primes[num_prime]*primes[num_prime]; floor = primes[num_prime]*primes[num_prime]; number1 = floor + Math.ceil(range/2*Math.random()); number2 = floor + Math.ceil(range/2*Math.random()+range/2)-1; number1_presented = Math.min(number1,number2); number2_presented = Math.max(number1,number2); person = personname(); QuestionText%QUESTION.NUMBER% = person+" wants to write program to determine whether or not a randomly chosen number between "+number1_presented+" and "+number2_presented+" is prime. "+ person+" knows this requires checking divisibility of this randomly chosen number by a list of primes. What is that list?

Input your answer in the box below as a sequence of increasing primes separated by commas and without spaces i.e. your list will start with 2,3,5, ...

" for(i_num = 1; i_num <= num_prime; i_num++){ list_of_primes[i_num-1] = primes[i_num];} Correct%QUESTION.NUMBER% = list_of_primes; // alert(Correct%QUESTION.NUMBER%); document.write(QuestionText%QUESTION.NUMBER%); document.write("") document.write("") } if (document.forms.name=="FEEDBACK") {} else {question%QUESTION.NUMBER%()} ]]> "Choice" INCLUDES NOCASE "was Correct"Well done!]]> "Choice" INCLUDES NOCASE "should have been"You were wrong!]]> OTHERYou should have tried this question!]]> if (document.forms.name=="FEEDBACK") { Count=document.forms.elements.length document.write(document.forms.elements[Count-1].value) var titleofpopup = "Related material"; var help = wheretolook("%QUESTION.TAGS%","%QUESTION.TOPIC%"); document.write("

"+""+"
") } // Template updated and developed by Daniel Nichols & Martin Greenhow, Brunel University, July 2004, working // on original templates authored by Dominic Smith of Brunel University, July 2001, with // valuable contributions from Professor David Hewitt of Monash University, Australia. ]]>
Level 1default_svgEasy function process%QUESTION.NUMBER%(QNo) { ANS= ""; ////// Start the solution SHOW="

SOLUTION:

"; var nwidth=getFontSize()/16*2700; var nheight=getFontSize()/16*50; var m1=""; var m2=""; var m3=""; var m4=""; e1="For this you need to remember the prime numbers: 2, 3, 5, 7, 11, 13, 17, 19, ... and a is a factor of b "+mathml_toggle("iff","if and only if"); e2="ba gives "+mathml_toggle("an integer.", "a whole number."); SHOW+=m0+e1+m5+m0+e2+m5; SHOW+="

"+m0+"So in this case we could have:"+m5+"

"; ////// work through two steps of the solution var curr=number_presented; var primes11= new Array(); primes11=jSort(primes1,0,primes1.length-1); var i=1; var check1=0; var check2=0; do{ var temp=Math.floor(curr/primes[i]); if(custRound(primes[i]*((curr/primes[i])-temp),0)==0){ SHOW+=m0+""+curr+""+primes[i]+"="+curr/primes[i]+" OK"+m5+"

"; curr/=primes[i]; check1++; }else{ SHOW+=m0+""+curr+""+primes[i]+"="+curr/primes[i]+" NOT OK"+m5+"

"; i++; check2++; } }while(check1<2 || check2<1) ////// output the rest of the solution SHOW+=m0+"continue this way with the list of primes and you will find that some won\&\#39;t be factors but the following will:"+m5+"

"; for(var i=2; i"+curr+""+primes11[i]+"="+curr/primes11[i]+" OK"+m5+"

"; curr = curr/primes11[i]; } SHOW+=m0+"and we stop here since the result is one."+m5+"

"; ///// the tree SHOW+="One way of showing this is by a factorisation tree, as follows

"+prime_fact_tree(primes11,2); for (var i=5; iYour answer "+document.forms.elements[item].value+" was correct.
"} else {document.forms.elements[item+3].value = "Your answer "+document.forms.elements[item].value+", should have been "+Correct%QUESTION.NUMBER%+"

"+ANS+"
"+SHOW+"
"} document.forms.elements[item+3].value = QuestionText%QUESTION.NUMBER% + document.forms.elements[item+3].value } function question%QUESTION.NUMBER%() { primes1 = new Array(); primes2 = new Array(); all_factors = new Array(); list_of_primes = new Array(); primes = new Array("",2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229) num_primes1 = Math.ceil(2*Math.random())+3; primes1_indices = displayarray(num_primes1,1,6,0); n_repeats = Math.ceil(2*Math.random()); for(n_rep = 0; n_rep < n_repeats; n_rep++){ primes1_indices[num_primes1] = primes1_indices[n_rep]; num_primes1 +=1; } number_presented = 1; for (iprimes1 = 0; iprimes1 Input your answer in the box below as a sequence of non-decreasing primes separated by commas and without spaces i.e. your list for 12 would be 2,2,3

" for(i_num = 0; i_num <= num_primes1; i_num++){ list_of_primes[i_num] = all_factors[i_num];} Correct%QUESTION.NUMBER% = jSort(list_of_primes,0,list_of_primes.length-1); Correct%QUESTION.NUMBER% = Correct%QUESTION.NUMBER%.toString(); Correct%QUESTION.NUMBER% = Correct%QUESTION.NUMBER%.substring(0,Correct%QUESTION.NUMBER%.length-1) //alert(all_factors); //document.write(Correct%QUESTION.NUMBER%+"

"+QuestionText%QUESTION.NUMBER%); document.write(QuestionText%QUESTION.NUMBER%); document.write("") document.write("") } if (document.forms.name=="FEEDBACK") {} else {question%QUESTION.NUMBER%()} function mathml_toggle(text1, text2){ //text1 will be the intital output then when clicked will be changed to text2 //text1 and text2 should be plain text, but you can change this, but must be mathml var code=""; code=""+text1+""+text2+""; return code; } function prime_fact_tree(primes,full){ // primes - array of the prime numbers in order want them showing (usualy smallest to largest) // full - 0 or ommited if want letters as output and no help // - 1 if want letters as output but help // - 2 if want the completed tree //check input if(full==null){ full=0; } // Product of Primes var tot=1; for(var i=0; i'; var svg_end=''; // output return svg_start+svg_body+svg_end; } ]]> "Choice" INCLUDES NOCASE "was Correct"Well done!]]> "Choice" INCLUDES NOCASE "should have been"You were wrong!]]> OTHERYou should have tried this question!]]> if (document.forms.name=="FEEDBACK") { Count=document.forms.elements.length document.write(document.forms.elements[Count-1].value) var titleofpopup = "Related material"; var help = wheretolook("%QUESTION.TAGS%","%QUESTION.TOPIC%"); document.write("

"+""+"
") } // Template updated and developed by Daniel Nichols & Martin Greenhow, Brunel University, July 2004, working // on original templates authored by Dominic Smith of Brunel University, July 2001, with // valuable contributions from Professor David Hewitt of Monash University, Australia. ]]>
Level 1default_svgEasy function process%QUESTION.NUMBER%(QNo){ QT=QuestionText%QUESTION.NUMBER% ET=EquationText%QUESTION.NUMBER% COR=Correct%QUESTION.NUMBER% ////// Start the solution SHOW="

SOLUTION:

"; var nwidth=getFontSize()/16*2700; var nheight=getFontSize()/16*50; var m1=""; var m2=""; var m3=""; var m4=""; e1="For this you need to remember the prime numbers: 2, 3, 5, 7, 11, 13, 17, 19, ... and a is a factor of b "+mathml_toggle("iff","if and only if"); e2="ba gives "+mathml_toggle("an integer.", "a whole number."); SHOW+=m0+e1+m5+m0+e2+m5; SHOW+="

"+m0+"So in this case we could have:"+m5+"

"; ////// work through two steps of the solution var curr=1; for(var i=0; i"+curr+""+primes[i]+"="+curr/primes[i]+" OK"+m5+"

"; curr/=primes[i]; check1++; }else{ SHOW+=m0+""+curr+""+primes[i]+"="+curr/primes[i]+" NOT OK"+m5+"

"; i++; check2++; } }while(check1<2 || check2<1) ////// output the rest of the solution SHOW+=m0+"continue this way with the list of primes and you will find that some won\&\39;t be factors but the following will:"+m5+"

"; for(var i=2; i"+curr+""+COR[i]+"="+curr/COR[i]+" OK"+m5+"

"; curr = curr/COR[i]; } SHOW+=m0+"and we stop here since the result is one."+m5+"

"; ///// the tree SHOW+="This gives the factorisation tree

"+prime_fact_tree(COR,2); ///// Find input box for (var i=11; i"; if(totcorr==0){ document.forms.elements[item+3].value += "

All your answers were wrong"; }else{ document.forms.elements[item+3].value += "

"+numbertext[totcorr]+" of your answers "+past_tense_is+" correct"; } document.forms.elements[item+3].value +=": you should have had"; for(var i=0; i"; }else{ document.forms.elements[item+3].value = "Your answers"; for(var i=0; iEnter a value in each box for the corresponding letter in the diagram:"; document.write(QuestionText%QUESTION.NUMBER%+EquationText%QUESTION.NUMBER%); QuestionText1%QUESTION.NUMBER%=""; for(var i=0; i"); } ///// Output a note to explain the order of the input QuestionText2%QUESTION.NUMBER% = "

Note: These numbers should be in non-decreasing order and you can have repeats i.e. A\&\le;B\&\le;C\&\le;D ...

"+""+"
") } ]]>
Level 1default_linearalgEasy function process%QUESTION.NUMBER%(QNo) { ANS= "Use Euclid\&\#39s algorithm to find the answer.
" SHOW = ""; for (var i=5; iYour answer "+document.forms.elements[item].value+" was correct.
"} else {document.forms.elements[item+3].value = "Your answer "+document.forms.elements[item].value+", should have been "+Correct%QUESTION.NUMBER%+"

"+ANS+"
"+SHOW+"
"} document.forms.elements[item+3].value = QuestionText%QUESTION.NUMBER% + document.forms.elements[item+3].value + Feedback%QUESTION.NUMBER%; } function question%QUESTION.NUMBER%() { all_factors = new Array(); primes1 = new Array(); primes2 = new Array(); primes = new Array("",2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229) num_primes1 = Math.ceil(2*Math.random())+2; primes1_indices = displayarray(num_primes1,5,10,0); n_repeats = Math.ceil(2*Math.random()); for(n_rep = 0; n_rep < n_repeats; n_rep++){ primes1_indices[num_primes1] = primes1_indices[n_rep]; num_primes1 +=1; } num_primes2 = Math.ceil(2*Math.random())+2; primes2_indices = displayarray(num_primes2,5,10,0); number_presented1 = 1; number_presented2 = 1; for (iprimes1 = 0; iprimes1 0.5) // cater for case when small divides large exactly if(i == 1){i = 0}; var fback=getrandommatrix(i+2,7,1,2); fback="LARGER VALUE"; fback="/"; fback="SMALLER VALUE OR REMAINDER FROM PREVIOUS LINE"; fback="="; fback="INTEGER PART OF THE DIVISION"; fback=""; fback="REMAINDER"; for(var j=0; j<=i; j++){ fback[j+2]=large[j]; fback[j+2]="/"; fback[j+2]=small[j]; fback[j+2]="="; fback[j+2]=Math.floor(large[j]/small[j]); fback[j+2]="rem"; fback[j+2]=ans[j]; } QuestionText%QUESTION.NUMBER% = "What is the Highest Common Factor (HCF) of "+number_presented1+" and "+number_presented2+"?

Input your answer in the box below.

Note that the Highest Common Factor (HCF) is also called the Greatest Common Divisor (GCD).

" Correct%QUESTION.NUMBER% = hcf_euclid(number_presented1,number_presented2); if(Correct%QUESTION.NUMBER% ==1){Feedback%QUESTION.NUMBER% = "Since the hcf is 1, then the two numbers are coprime.
"}else{Feedback%QUESTION.NUMBER% = create_table(fback)}; // alert(Correct%QUESTION.NUMBER%); document.write(QuestionText%QUESTION.NUMBER%); document.write("") document.write("") } if (document.forms.name=="FEEDBACK") {} else {question%QUESTION.NUMBER%()} ////////////////// // Table Creator // ////////////////// function create_table(values){ // Table variable var Table=""; // Table data settings var td = "" // Table heading settings var th = "" // Find the dimensions of the matrix var size=MatrixSize(values); // Output the header row Table = ""; for(var i=1; i<=size; i++){ Table += th+values[i]+""; } Table +=""; // Output the rest of the rows for(var i=2; i<=size; i++){ Table += ""; for(var j=1; j<=size; j++){ if(values[i][j]=="INPUTBOX"){ Table += ""; }else{ Table += td+values[i][j]+""; } } Table += ""; } // Close the Table Table += "
"; return Table; } ]]> "Choice" INCLUDES NOCASE "was Correct"Well done!]]> "Choice" INCLUDES NOCASE "should have been"You were wrong!]]> OTHERYou should have tried this question!]]> if (document.forms.name=="FEEDBACK") { Count=document.forms.elements.length document.write(document.forms.elements[Count-1].value) var titleofpopup = "Related material"; var help = wheretolook("%QUESTION.TAGS%","%QUESTION.TOPIC%"); document.write("

"+""+"
") } // Template updated and developed by Daniel Nichols & Martin Greenhow, Brunel University, July 2004, working // on original templates authored by Dominic Smith of Brunel University, July 2001, with // valuable contributions from Professor David Hewitt of Monash University, Australia. ]]>
Level 1default_linearalgEasy function process%QUESTION.NUMBER%(QNo) { var nwidth=getFontSize()/16*2700; var nheight=getFontSize()/16*50; var m1=""; var m2=""; var m3=""; var m4=""; ANS= m0+"You should have used the formula a×bgcd(a,b). Using Euclid\&\#39s algorithm to find the "+mathml_toggle("GCD","Greatest Common Divisor") +"   gives the table"+m5+"
"; SHOW = Feedback%QUESTION.NUMBER%; for (var i=5; iYour answer "+document.forms.elements[item].value+" was correct.
"} else {document.forms.elements[item+3].value = "Your answer "+document.forms.elements[item].value+", should have been "+Correct%QUESTION.NUMBER%+"

"+ANS+"
"+SHOW+"
"} document.forms.elements[item+3].value = QuestionText%QUESTION.NUMBER% + document.forms.elements[item+3].value; } function question%QUESTION.NUMBER%() { all_factors = new Array(); primes1 = new Array(); primes2 = new Array(); primes = new Array("",2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229) num_primes1 = Math.ceil(2*Math.random())+3; primes1_indices = displayarray(num_primes1,1,6,0); num_primes2 = Math.ceil(2*Math.random())+3; primes2_indices = displayarray(num_primes2,1,8,0); n_repeats = Math.ceil(2*Math.random()); for(n_rep = 0; n_rep < n_repeats; n_rep++){ primes1_indices[num_primes1] = primes1_indices[n_rep]; num_primes1 +=1; } number_presented1 = 1; number_presented2 = 1; for (iprimes1 = 0; iprimes1 0.5) // cater for case when small divides large exactly if(i == 1){i = 0}; var fback=getrandommatrix(i+2,7,1,2); fback="LARGER VALUE"; fback="/"; fback="SMALLER VALUE OR REMAINDER FROM PREVIOUS LINE"; fback="="; fback="INTEGER PART OF THE DIVISION"; fback=""; fback="REMAINDER"; for(var j=0; j<=i; j++){ fback[j+2]=large[j]; fback[j+2]="/"; fback[j+2]=small[j]; fback[j+2]="="; fback[j+2]=Math.floor(large[j]/small[j]); fback[j+2]="rem"; fback[j+2]=ans[j]; } Correct%QUESTION.NUMBER% = number_presented1; temp = number_presented1; for (iprimes2 = 0; iprimes2 Input your answer in the box below.

" //alert(Correct%QUESTION.NUMBER%); hcf = hcf_euclid(number_presented1,number_presented2); Feedback%QUESTION.NUMBER%=create_table(fback)+"

So GCD="+hcf+" and thus LCM=("+number_presented1+" × "+number_presented2+")/"+hcf+"="+Correct%QUESTION.NUMBER%+"

"; document.write(QuestionText%QUESTION.NUMBER%); document.write("") document.write("") } if (document.forms.name=="FEEDBACK") {} else {question%QUESTION.NUMBER%()} function mathml_toggle(text1, text2){ //text1 will be the intital output then when clicked will be changed to text2 //text1 and text2 should be plain text, but you can change this, but must be mathml var code=""; code=""+text1+""+text2+""; return code; } ////////////////// // Table Creator // ////////////////// function create_table(values){ // Table variable var Table=""; // Table data settings var td = "" // Table heading settings var th = "" // Find the dimensions of the matrix var size=MatrixSize(values); // Output the header row Table = ""; for(var i=1; i<=size; i++){ Table += th+values[i]+""; } Table +=""; // Output the rest of the rows for(var i=2; i<=size; i++){ Table += ""; for(var j=1; j<=size; j++){ if(values[i][j]=="INPUTBOX"){ Table += ""; }else{ Table += td+values[i][j]+""; } } Table += ""; } // Close the Table Table += "
"; return Table; } ]]> "Choice" INCLUDES NOCASE "was Correct"Well done!]]> "Choice" INCLUDES NOCASE "should have been"You were wrong!]]> OTHERYou should have tried this question!]]> if (document.forms.name=="FEEDBACK") { Count=document.forms.elements.length document.write(document.forms.elements[Count-1].value) var titleofpopup = "Related material"; var help = wheretolook("%QUESTION.TAGS%","%QUESTION.TOPIC%"); document.write("

"+""+"
") } // Template updated and developed by Daniel Nichols & Martin Greenhow, Brunel University, July 2004, working // on original templates authored by Dominic Smith of Brunel University, July 2001, with // valuable contributions from Professor David Hewitt of Monash University, Australia. ]]>