![akkira02](/avatars/41158.jpg)
akkira02
13.12.2020 •
Computers and Technology
I am giving away A TON of points. Can I please get some help writing this code? It is a bit confusing to me? Is it possible to write it in the simplest form possible?
Task:
A Harris number is a number that is divisible by the sum of its digits. For example, the number 81 is a Harris number because the sum of its digits is 9 and 81 is divisible by 9.
A Flavius sequence is a numerical sequence that is generated under the following rules:
If n = 1, the sequence ends
if n is even, the next n is n/2
if n is odd, the next n is 3n + 1
There is a theorem that states that every positive integer n will generate a finitely long Flavius sequence. For example:
n=3: 3, 10, 5, 16, 8, 4, 2, 1
n=7: 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1
Flavius sequences are often identified as (n, sequence length), so (3, 8) or (7, 17).
Your task:
Write a program that prompts a user for an unknown number of numbers. The user will input positive integers one at a time and the system will respond whether or not the number is a Harris number and what the Flavius sequence length is. When the user enters an integer of 0 or less, the program will end and the following statistics will be displayed: The count of all Harris numbers entered and the longest Flavius sequence in the form (n, length).
Your program should have the following:
A method that determines whether or not a number is a Harris number and returns True or False
A method that calculates and returns the length of the Flavius sequence for any positive integer
A main (driving) portion of the program
Your code page should be commented appropriately. See the Number Fun program for examples of what should be included.
Solved
Show answers
More tips
- H Health and Medicine Heartburn: Causes and Ways to Get Rid of It...
- H Health and Medicine Simple and Effective: How to Get Rid of Cracked Heels...
- H Health and Medicine Relieving Swelling in Legs: Causes and Ways to Alleviate the Symptom...
- W Work and Career Мерчендайзинг – все, что нужно знать...
- O Other Everything You Need to Know About Kudyabliks...
- F Food and Cooking How to cook crayfish? Everything you need to know...
- F Food and Cooking Homemade kvass: recipe and brewing process...
- H Health and Medicine How to Choose the Right Tanning Cream?...
- S Style and Beauty Secrets of Tying a Pareo: 5 Ways...
- S Sport Running: How to Do It Right?...
Answers on questions: Computers and Technology
- B Business What were the major parts of hamilton s financial plan....
- S Social Studies Inst, Tok, and Tube all wanted to be followed or subscribed. would the easiest strategy to be go on tktok and finding them? or is it joenewman_author on tito and press...
- E Engineering What do means by tenes...
- M Mathematics Please Solve as Fast as You Can The coordinates of Point A are (-1, 4). If Point A is reflected across the x-axis AND then across the y-axis, what are the coordinates...
Ответ:
short_names = ["Gus", "Bob", "Ann"]
print(short_names[0])
print(short_names[1])
print(short_names[2])
Explanation:
There are some typos in your code. In addition to the missing part of the code, I corrected the typos.
First of all, initialize the list called short_names. The list starts with "[" and ends with "]". Between those, there are must be the names (Since each name is a string, they must be written between "" and there must be a semicolon between each name)
Then, you can print each name by writing the name of the list and the index of the names between brackets (Index implies the position of the element and it starts with 0)