'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; i 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[0].name=="FEEDBACK")
{}
else
{question%QUESTION.NUMBER%()}
]]>
"}
else
{document.forms[0].elements[item+3].value =
"Your answer "+document.forms[0].elements[item].value+", should have been "+Correct%QUESTION.NUMBER%+"
"+ANS+"
"+SHOW+" "}
document.forms[0].elements[item+3].value = QuestionText%QUESTION.NUMBER% + document.forms[0].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?
SOLUTION:
";
var nwidth=getFontSize()/16*2700;
var nheight=getFontSize()/16*50;
var m1="";
e1="
"+m0+"
";
////// 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];
check1++;
}else{
SHOW+=m0+"
";
i++;
check2++;
}
}while(check1<2 || check2<1)
////// output the rest of the solution
SHOW+=m0+"
";
for(var i=2; i ";
curr = curr/primes11[i];
}
SHOW+=m0+" ";
///// the tree
SHOW+="One way of showing this is by a factorisation tree, as follows "+prime_fact_tree(primes11,2);
for (var i=5; i "
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[0].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="
"}
else
{document.forms[0].elements[item+3].value =
"Your answer "+document.forms[0].elements[item].value+", should have been "+Correct%QUESTION.NUMBER%+"
"+ANS+"
"+SHOW+" "}
document.forms[0].elements[item+3].value = QuestionText%QUESTION.NUMBER% + document.forms[0].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
SOLUTION:
";
var nwidth=getFontSize()/16*2700;
var nheight=getFontSize()/16*50;
var m1="";
e1="
"+m0+"
";
////// work through two steps of the solution
var curr=1;
for(var i=0; i ";
curr/=primes[i];
check1++;
}else{
SHOW+=m0+" ";
i++;
check2++;
}
}while(check1<2 || check2<1)
////// output the rest of the solution
SHOW+=m0+" ";
for(var i=2; i ";
curr = curr/COR[i];
}
SHOW+=m0+" ";
///// the tree
SHOW+="This gives the factorisation tree "+prime_fact_tree(COR,2);
///// Find input box
for (var i=11; i All your answers were wrong";
}else{
document.forms[0].elements[item+3].value += " "+numbertext[totcorr]+" of your answers "+past_tense_is+" correct";
}
document.forms[0].elements[item+3].value +=": you should have had";
for(var i=0; i ";
}else{
document.forms[0].elements[item+3].value = "Your answers";
for(var i=0; i Enter 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 Note: These numbers should be in non-decreasing order and you can have repeats i.e. A\&\le;B\&\le;C\&\le;D ... ";
document.write(QuestionText2%QUESTION.NUMBER%);
document.write("")
}
if (document.forms[0].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="
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[0].name=="FEEDBACK")
{}
else
{question%QUESTION.NUMBER%()}
//////////////////
// Table Creator //
//////////////////
function create_table(values){
// Table variable
var Table="";
// Table data settings
var td = "
"; }else{ Table += td+values[i][j]+""; } } Table += " |
" //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[0].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="
"; }else{ Table += td+values[i][j]+""; } } Table += " |