Remember: the best way to learn to code is to write code! So let’s practice our loops. Pick one of the following prompts. And most importantly: have fun! If you get done early, pick another one!
Write a program that prompts the user to enter a positive integer n and then computes the sum of the numbers from 1 through n. For example, if the user enters 5, then your program’s output should be:
Write a program that continuously asks the user to enter a nonzero number and adds up all of the numbers entered. The program should terminate when the user enters a zero and then print out the total sum.
Write a program that prompts the user for two numbers p and q, then calculates the greatest common divisor of p and q. You may do so using the "brute force" method: If q\(\leq\)p, for example, you simply check each of the divisors q, q-1, q-2, ..., 1, until you find one that divides both p and q.
Write a program that determines whether a number entered by the user is prime (again, you may use the “brute force” method, going through all possible divisors 2, 3, 4, …, n).