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...
C++ coding plase Given three integer numbers N1, N2 and N3. Write 2 overloaded functions which...
C++ coding plase Given three integer numbers N1, N2 and N3. Write 2 overloaded functions which perform addition of passed values. Write two functions inside 'ProblemSolution' class: Function 1: solution that accepts two parameters, N1 and N2. A function should return addition of those numbers. Function 2: solution that accepts three parameters, N1, N2 and N3. A function should return addition of 3 numbers. Input     2     3     4 Output     5     9 Where, The first line of output contains addition of...
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.
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):
Programming language Python It have to be in Functions with a main function Samuel is a...
Programming language Python It have to be in Functions with a main function Samuel is a math teacher at Hogwarts School of Witchcraft and Wizardry. He loves to give his students multiplication exercises. However, he doesn’t care about the actual operation result but the unit sum of its digits. At Hogwarts School of Witchcraft and Wizardry, they define the unit sum (US) of N as the unit that it is left after doing the sum of all the digits of...
Suppose two independent random samples of sizes n1 = 9 and n2 = 7 that have...
Suppose two independent random samples of sizes n1 = 9 and n2 = 7 that have been taken from two normally distributed populations having variances σ12 and σ22 give sample variances of s12 = 117 and s22 = 19. (a) Test H0: σ12 = σ22 versus Ha: σ12 ≠ σ22 with σ = .05. What do you conclude? (Round your answers to 2 decimal places.) F = F.025 = H0:σ12 = σ22 (b) Test H0: σ12 < σ22versus Ha: σ12...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT