Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

So iv uploaded this before and got a answer and i was going over what the person had given to me but then the post

So iv uploaded this before and got a answer and i was going over what the person had given to me but then the post just vanished. So onece again this is a PHP server side code that im trying to setup help with this would be great

image text in transcribedimage text in transcribed

Summary For this assignment, we will tackle the Collatz Conjecture. It is possibly the simplest unsolved problem in mathematics which is exactly what makes it so dangerous. We will not solve it, but simply test it. This problem will help us with basic arithmetic operations, post backs, data validation, and dynamic HTML. Really, what more could we want in a simple unsolved math problem! Specifications 1. Lothar Collatz posed the conjecture in the 1930s. 2. The problem sounds, and is very simple. Do the following: a. Pick a number, any number. b. If it's odd, multiply it by 3 and add 1. c. If it's even, divide it by 2. d. Now you have a new number. Apply the same rules to the new number. 3. The conjecture is about what happens as you keep repeating the process. 4. Collatz conjectured that if you start with a positive whole number and run this process long enough, all starting values will lead to 1. 5. And once you hit 1, the rules of the Collatz conjecture confine you to a loop: 1, 4, 2, 1, 4, 2, 1, ... forever. 6. The following image comes from https://www.quantamagazine.org/ Testing Collatz The conjecture uses the following algorithm: If the number is even, divide it by 2, otherwise multiply by 3 and add 1. Repeat. Can you find a starting number that doesn't get stuck at 1? in-11 RESULTS: is. n - 13 RESULTS: #1: 40 #2:20 43:10 is n-320 RESULTS #1 160 ie n = 640 RESULTS: #1: 320 #2: 160 #2: 80 #2:17 43:52 #4:26 #5:13 #5:16 43:40 #4:20 #5:10 #6:5 #7: 16 # #6: 8 #8:8 #9:4 # # 111 # 7. We have not found a number which does not end in 1, but we cannot prove that EVERY positive integer will eventually end with 1. 8. Create a page (index.php) which contains the following: a. A Textbox for the user to enter the starting number. b. A Button for the user to start the process. 9. Limit the input to a positive integer from 5 to 20,000. 10. If the user enters an invalid number or a number outside of the range, then display an error message and let the user enter a number again. 11. If the user enters a valid integer within range, then display the sequence in a ordered-list (ol) element. Once the list is displayed, display the number of iterations it took to get to 1. 12. NOTE: Make sure you page works correctly if the user refreshes the page (F5). Documentation A text document (.docx, .itf, .pdf) which contains the following: . Your name and assignment. Your responses to the following questions: o What are the eight arithmetic operators in PHP? Give an example of each. o What are the eleven comparison operators in PHP? Give an example of each. o Explain dynamic typing and how it impacts comparisons. A screenshot showing your page running with three different test cases. You can use the sample listed in the is assignment to make sure your code works as expected. Make sure your screenshots include the URL! Summary For this assignment, we will tackle the Collatz Conjecture. It is possibly the simplest unsolved problem in mathematics which is exactly what makes it so dangerous. We will not solve it, but simply test it. This problem will help us with basic arithmetic operations, post backs, data validation, and dynamic HTML. Really, what more could we want in a simple unsolved math problem! Specifications 1. Lothar Collatz posed the conjecture in the 1930s. 2. The problem sounds, and is very simple. Do the following: a. Pick a number, any number. b. If it's odd, multiply it by 3 and add 1. c. If it's even, divide it by 2. d. Now you have a new number. Apply the same rules to the new number. 3. The conjecture is about what happens as you keep repeating the process. 4. Collatz conjectured that if you start with a positive whole number and run this process long enough, all starting values will lead to 1. 5. And once you hit 1, the rules of the Collatz conjecture confine you to a loop: 1, 4, 2, 1, 4, 2, 1, ... forever. 6. The following image comes from https://www.quantamagazine.org/ Testing Collatz The conjecture uses the following algorithm: If the number is even, divide it by 2, otherwise multiply by 3 and add 1. Repeat. Can you find a starting number that doesn't get stuck at 1? in-11 RESULTS: is. n - 13 RESULTS: #1: 40 #2:20 43:10 is n-320 RESULTS #1 160 ie n = 640 RESULTS: #1: 320 #2: 160 #2: 80 #2:17 43:52 #4:26 #5:13 #5:16 43:40 #4:20 #5:10 #6:5 #7: 16 # #6: 8 #8:8 #9:4 # # 111 # 7. We have not found a number which does not end in 1, but we cannot prove that EVERY positive integer will eventually end with 1. 8. Create a page (index.php) which contains the following: a. A Textbox for the user to enter the starting number. b. A Button for the user to start the process. 9. Limit the input to a positive integer from 5 to 20,000. 10. If the user enters an invalid number or a number outside of the range, then display an error message and let the user enter a number again. 11. If the user enters a valid integer within range, then display the sequence in a ordered-list (ol) element. Once the list is displayed, display the number of iterations it took to get to 1. 12. NOTE: Make sure you page works correctly if the user refreshes the page (F5). Documentation A text document (.docx, .itf, .pdf) which contains the following: . Your name and assignment. Your responses to the following questions: o What are the eight arithmetic operators in PHP? Give an example of each. o What are the eleven comparison operators in PHP? Give an example of each. o Explain dynamic typing and how it impacts comparisons. A screenshot showing your page running with three different test cases. You can use the sample listed in the is assignment to make sure your code works as expected. Make sure your screenshots include the URL

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions