daily pastebin goal
11%
SHARE
TWEET

Untitled

a guest Jan 12th, 2018 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script language="JavaScript">
  2. <!-- HIDE
  3.  
  4. var k1 = 0
  5. var k2 = 0
  6. var n1 = 0
  7. var n2 =0
  8. var a = 0
  9. var b = 0
  10. var c = 0
  11. var af1 = new Array(10)
  12. var af2 = new Array(10)
  13. var cf1 = new Array(10)
  14. var cf2 = new Array(10)
  15. var lasta = 0
  16. var lastc = 0
  17. var aoutput = new Array(10)
  18. var afactors = ""
  19. var coutput = new Array(10)
  20. var cfactors = ""
  21. var bsign = ""
  22. var csign = ""
  23. var outputa = ""
  24.  
  25.  
  26. function showProblem() {
  27.    var ran1 = Math.random() * (6) + 1
  28.    var ran2 = Math.random() * (6) + 1
  29.    var ran3 = Math.random() * (6) + 1
  30.    var ran4 = Math.random() * (6) + 1
  31.    k1 = Math.floor(ran1)
  32.    k2 = Math.floor(ran2)
  33.    n1 = Math.floor(ran3)
  34.    n2 = Math.floor(ran4)
  35.    a = k1 * k2
  36.    b = k1 * n2 + k2 * n1
  37.    c = n1 * n2
  38.    if (a%2 == 0 && b%2 == 0 && c%2==0) {showProblem()}
  39.    if (a%3 == 0 && b%3 == 0 && c%3==0) {showProblem()}
  40.    if (a%5 == 0 && b%5 == 0 && c%5==0) {showProblem()}
  41.    if (a%7 == 0 && b%7 == 0 && c%7==0) {showProblem()}
  42.  
  43.  
  44.   if (a == 1) {outputa = ""}
  45.   else outputa = a
  46.  
  47.   if (b < 0) {
  48.        bsign = " - "
  49.        if (b==-1) {outputb = ""}
  50.        else {
  51.           outputb = -1*b
  52.        }
  53.    }
  54.    else {
  55.      bsign = " + "
  56.      if (b==1) {outputb = ""}
  57.        else {
  58.            outputb = b
  59.        }
  60.    }
  61.  
  62.  if (c < 0) {
  63.        csign = " - "
  64.        if (c==-1) {outputc = "1"}
  65.        else {
  66.           outputc = -1*c
  67.        }
  68.    }
  69.    else {
  70.      csign = " + "
  71.       outputc = c
  72.    }
  73.  
  74.    if(b==0) {document.theForm.output1.value = outputa + "x^2"  + csign + outputc }
  75.    else
  76.    {document.theForm.output1.value = outputa + "x^2" + bsign+ outputb + "x" + csign + outputc}
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.    lasta = Math.ceil(Math.sqrt(a) + 1)
  85.    lastc = Math.ceil(Math.sqrt(c) + 1)
  86.    afactors = ""
  87.    cfactors = ""
  88.  
  89.    for (var i = 0; i < 9; i++) {
  90.       af1[i] = 0
  91.       af2[i] = 0  
  92.       cf1[i] = 0
  93.       cf2[i] = 0
  94.     }
  95.  
  96.    for (var i = 1; i < lasta; i++){
  97.        af1[i] = a/i
  98.        af2[i] = a/af1[i]
  99.        if (a%i == 0) {
  100.            if (af2[i] > af1[i]) {aoutput[i] = ""}
  101.            else
  102.            aoutput[i] = af1[i] + "e" + af2[i] + "  "
  103.        }
  104.        else  aoutput[i] = ""
  105.        afactors = afactors + aoutput[i]    
  106.     }
  107.   for (var i = 1; i < lastc; i++){
  108.        cf1[i] = c/i
  109.        cf2[i] = c/cf1[i]
  110.        if (c%i == 0) {
  111.            if (cf2[i] > cf1[i]) {coutput[i] = ""}
  112.            else
  113.            coutput[i] = cf1[i] + "e" + cf2[i] + "  "
  114.        }
  115.        else  coutput[i] = ""
  116.        cfactors = cfactors + coutput[i]    
  117.     }
  118.  
  119. }
  120.  
  121. function showStep2() {
  122.     document.theForm.output2.value = afactors
  123. }
  124.  
  125. function showStep3() {
  126.     document.theForm.output3.value = cfactors
  127. }
  128.  
  129. function showStep4() {
  130.     document.theForm.output4.value =  k1 +"e"+k2
  131. }
  132.  
  133. function showStep5() {
  134.     document.theForm.output5.value = n1+"e"+n2
  135. }
  136.  
  137. function doProblem() {
  138.     var outputk1 = ""
  139.     var outputk2 = ""
  140.     if (k1 != 1) {outputk1 = k1}
  141.     if (k2 != 1) {outputk2 = k2}
  142.     document.theForm.output6.value = "(" + outputk1 + "x + " + n1 + ")(" +outputk2 + "x + " + n2 + ")"
  143. }
  144.  
  145.  
  146.  
  147.  
  148. //STOP HIDING -->
  149.   </script>
RAW Paste Data
Top