Question

In: Computer Science

Programming language in Python Suppose, for Jane, n1 = 3, n2 = 4, and n3 =...

Programming language in Python

Suppose, for Jane, n1 = 3, n2 = 4, and n3 = 5. Also suppose, Jane iterates the number from 1 to 15.
At the beginning, Jane sets count to 0, and then proceeds iterating the number from 1 to 15 and for each iteration does the following:

for 1, count is increased by 1 because it is not divisible by 3, 4, and 5; count is now: 1
for 2, count is increased by 2 because it is not divisible by 3, 4, and 5; count is now: 3
for 3, count is increased by 1 because it is divisible by 3; count is now: 4
for 4, count is increased by 2 because it is divisible by 4; count is now: 6
for 5, count is increased by 3 because it is divisible by 5; count is now: 9
for 6, count is increased by 1 because it is divisible by 3; count is now: 10
for 7, count is increased by 7 because it is not divisible by 3, 4, and 5; count is now: 17
for 8, count is increased by 2 because it is divisible by 4; count is now: 19
for 9, count is increased by 1 because it is divisible by 3; count is now: 20
for 10, count is increased by 3 because it is divisible by 5; count is now: 23
for 11, count is increased by 11 because it is not divisible by 3, 4, and 5; count is now: 34

for 12, count is increased by 1 because it is divisible by 3, count is increased by 2 because it is divisible by 4; count is now: 37

for 13, count is increased by 13 because it is not divisible by 3, 4, and 5; count is now: 50
for 14, count is increased by 14 because it is not divisible by 3, 4, and 5; count is now: 64

for 15, count is increased by 1 because it is divisible by 3, count is increased by 3 because it is divisible by 5; count is now: 68

The final answer should be: 68


Please note: for 12, because it was divisible by both n1, and n2, both 1 and 2 were added. Similarly,
for 15, because it was divisible by both n1 and n3, both 1 and 3 were added.

Solutions

Expert Solution

Please look at my code and in case of indentation issues check the screenshots.

--------------main.py---------------


def main():
   n1 = 3                               #initialize values of n1, n2, n3
   n2 = 4
   n3 = 5
   count = 0                           #intialize count to 0
   for i in range(1, 16):               #loop from i = 0 to i = 15
       divisible = False               #to check if any one number out of n1, n2, n3 divides i
       if i % n1 == 0:                   #if n1 divides i, increase count by 1
           count = count + 1
           divisible = True
       if i % n2 == 0:                   #if n2 divides i, increase count by 2
           count = count + 2
           divisible = True
       if i % n3 == 0:                   #if n3 divides i, increase count by 3
           count = count + 3
           divisible = True
       if not divisible:               #if none of the number divides i
           count = count + i            #then increase count by i
       print("i =", i, ", count =", count)

main()

----------Screenshots--------------------

----------Output--------------

------------------------------------------------------

Please give a thumbs up if you find this answer helpful.
If it doesn't help, please comment before giving a thumbs down.
Please Do comment if you need any clarification.
I will surely help you.

Thankyou


Related Solutions

If n1<n2 and n3<n2, which of the following statements are true when it comes to finding...
If n1<n2 and n3<n2, which of the following statements are true when it comes to finding out if you have destructive interference of the reflected rays? You do need to know if n1 is bigger or smaller than n3. You cannot make any calculations unless you know the numerical value of n3. You cannot make any calculations unless you know the numerical value of n2. The reflected ray from the interface between medium 1 and medium 2 will undergo a...
Xiku Road has n1,n2,n3, and n4 houses with 1,2,3, and 4 occupants, respectively. Two random selection...
Xiku Road has n1,n2,n3, and n4 houses with 1,2,3, and 4 occupants, respectively. Two random selection without replacement strategies are being contemplated to obtain a sample of the residents. In the first strategy, residents are selected with equal probability. In the second strategy, houses are first randomly selected and then residents from these houses are selected. Work out, in terms of n1,n2,n3, and n4, the conditional probability of a resident from a 3-occupant house being selected given that the first...
Let N1 , N2 , N3 follow a trinomial distribution with parameters n, assume that n...
Let N1 , N2 , N3 follow a trinomial distribution with parameters n, assume that n follows a Poisson distribution with parameter λ > 0. Also assume that, conditionally on N, the random variables N1, N2, N3 follow a trinomial distribution with N trials and category probabilities p1, p2, p3 with p1 + p2 + p3 = 1. Compute the covariance and correlation of (N1,N2)
Programming language is in python 3 For this project, you will import the json module. Write...
Programming language is in python 3 For this project, you will import the json module. Write a class named NobelData that reads a JSON file containing data on Nobel Prizes and allows the user to search that data. It just needs to read a local JSON file - it doesn't need to access the internet. Specifically, your class should have an init method that reads the file, and it should have a method named search_nobel that takes as parameters a...
Programming language is python 3 For this project, you will import the json module. Write a...
Programming language is python 3 For this project, you will import the json module. Write a class named NeighborhoodPets that has methods for adding a pet, deleting a pet, searching for the owner of a pet, saving data to a JSON file, loading data from a JSON file, and getting a set of all pet species. It will only be loading JSON files that it has previously created, so the internal organization of the data is up to you. The...
The programming language is Python Instructions: Create a function that will delete a node in a...
The programming language is Python Instructions: Create a function that will delete a node in a Linked List based on position number. On below example, if you want to delete position #2, it will remove the Banana (arrangement of nodes below is Apple, Banana, Cherry, Grapes, Orange). myLinkedList = LinkedList() myLinkedList.append("Banana") myLinkedList.append("Cherry") myLinkedList.append("Grapes") myLinkedList.append("Orange") myLinkedList.prepend("Apple") myLinkedList.deleteByPositionNum(2) node = myLinkedList.head while node: print(node.value, " ") node = node.next_node You may start with the function head: def deleteByPositionNum(self, positionNum):
Question 3: A double sampling plan is such that n1=50=n2, c1=1 and c2=4. If the fraction...
Question 3: A double sampling plan is such that n1=50=n2, c1=1 and c2=4. If the fraction nonconforming is ? =0.15, what is the probability of acceptance on the first sample? What is the probability of the final acceptance? Calculate the probability of rejection on the first sample.
a summary explaining the basic understanding of the following programming concepts using a language of python:...
a summary explaining the basic understanding of the following programming concepts using a language of python: •Variables •Arithmetic and Logical operations •Sequential coding (Structured programming •Decision structure (If statements) •Repetition structure •Functions with some coding demos inside visual studio code python IDE which can be sent as screenshot. preferably a typed summary please which can be written into powerpoint pleaseeeee ???
Use the Python programming language to complete below (I need the New Answer for this, and...
Use the Python programming language to complete below (I need the New Answer for this, and please provide the screenshot of the source code. Thank you!): Write a function to seek for all even numbers and odd numbers in the middle of two number A and B. Print even and odd numbers in 1 and 2020 (including both these two numbers)
Use the Python programming language to complete below (I need the New Answer for this, and...
Use the Python programming language to complete below (I need the New Answer for this, and please provide the screenshot of the source code. Thank you!): A website requests an user to input his account password. Write a program to examize the validity of the password. The valid password must consists of: At least 1 letter in [a-z] At least 1 number in [0-9] At least a letter in [A-Z] (capital) At least one special letter in [$#@] At least...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT