Advertisement
Guest User

Untitled

a guest
Dec 4th, 2021
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. <html>
  2.  
  3. <head> </head>
  4.  
  5. <body>
  6.  
  7. <script src="https://www.desmos.com/api/v1.6/calculator.js?apiKey=dcb31709b452b1cf9dc26972add0fda6"> </script>
  8.  
  9. <div id="calculator" style="width: 1920px; height: 1080px;"></div>
  10.  
  11. <script>
  12. var elt = document.getElementById('calculator');
  13. var calculator = Desmos.GraphingCalculator(elt);
  14.  
  15. let n = 5; // <----- CHANGE THIS NUMBER TO WHATEVER YOU WANT THE SEQUENCE TO START AT
  16. while (n != 1) {
  17. let isEven = (n % 2 === 0);
  18. let next = isEven ? n / 2 : 3*n + 1;
  19. let h = (n + next)/2;
  20. let dist = Math.sqrt( Math.pow(h - n, 2) );
  21.  
  22. calculator.setExpression({
  23. id : `graph${n}`,
  24. latex: `(x - ${h})^2 + y^2 = (${dist})^2 \\{ y ${isEven ? "<" : ">"} 0 \\}`,
  25. color: isEven ? Desmos.Colors.BLUE : Desmos.Colors.RED
  26. });
  27. n = next;
  28. }
  29.  
  30. let h = (5)/2;
  31. // Add the 1 -4 loop manually
  32. let dist = Math.sqrt( Math.pow(h - 1, 2) );
  33. calculator.setExpression({
  34. id: 'graphend',
  35. latex: `(x - ${h})^2 + y^2 = (${dist})^2 \\{ y > 0 \\}`,
  36. color: Desmos.Colors.RED
  37. });
  38.  
  39.  
  40. </script>
  41.  
  42. </body>
  43.  
  44. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement