1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
atroni [7]
3 years ago
9

Given a positive integer n, assign true to is_prime if n has no factors other than 1 and itself. (remember, m is a factor of n i

f m divides n evenly.)
Mathematics
2 answers:
yawa3891 [41]3 years ago
6 0
This is the following condition in order to get the specific output for this specific problem: if is_a_prime(n):<span>    is_prime = True</span> <span><span>Now all you have to do is write is_a_prime().

For the hard code for this problem:

</span>if n == 2:<span>
is_prime = True
elif n % 2 == 0:
is_prime = False
else:
is_prime = True 
for m in range (3, int (n * 0.5) + 1, 2): 
if n % m == 0: 
is_prime = False 
<span>break.</span></span></span> 
<span>
To add, a high-level programming language that is widely used for general-purpose programming<span>, created by Guido van Rossum and first released in 1991 is called Python.</span></span>
vlada-n [284]3 years ago
3 0

Below is the solution of assign true to is_prime if n has no factors other than 1 and itself.

<h3>Further explanation </h3>

Python is an interpreted, high-level, general-purpose programming language. Python is created by Guido van Rossum and first released in 1991. Its design philosophy emphasizes code readability. Python is a more productive language than Java because it is an interpretive language which is accompanied by elegant syntax and it makes an excellent choice for scripting and rapid application development in many areas. Python is a general-purpose, versatile and popular because it is concise and easy to read, and it is also a good language to have in any programmer’s stack as it can be used for everything such as web development, software development, data science applications.

Given a positive integer n, assign true to is_prime if n has no factors other than 1 and itself. And remember, m is a factor of n if m divides n evenly. So:

<em> if n == 2: </em>

<em>is_prime = True </em>

<em>elif n % 2 == 0: </em>

<em>is_prime = False </em>

<em>else: </em>

<em>is_prime = True </em>

<em>for m in range (3, int(n**0.5)+1, 2): </em>

<em>if n % m == 0: </em>

<em>is_prime = False</em>

<h3>Learn more</h3>
  1. Learn more about python brainly.com/question/4331067
  2. Learn more about python IDLE or similar environment  brainly.com/question/6280029
  3. Learn more about python function brainly.com/question/9806744

<h3>Answer details</h3>

Grade:  9

Subject:  mathematics

Chapter:  python

Keywords:  python, integer, factors, python IDLE, <em>is_prime</em>

You might be interested in
What is the slope-intercept equation
viva [34]
The answer is y= -1/2 + (-4)
4 0
2 years ago
5.2.14. For the negative binomial pdf p (k; p, r) = k+r−1 (1 − p)kpr, find the maximum likelihood k estimator for p if r is know
Volgvan

Answer:

\hat p = \frac{r}{\bar x +r}

Step-by-step explanation:

A negative binomial random variable "is the number X of repeated trials to produce r successes in a negative binomial experiment. The probability distribution of a negative binomial random variable is called a negative binomial distribution, this distribution is known as the Pascal distribution".

And the probability mass function is given by:

P(X=x) = (x+r-1 C k)p^r (1-p)^{x}

Where r represent the number successes after the k failures and p is the probability of a success on any given trial.

Solution to the problem

For this case the likehoof function is given by:

L(\theta , x_i) = \prod_{i=1}^n f(\theta ,x_i)

If we replace the mass function we got:

L(p, x_i) = \prod_{i=1}^n (x_i +r-1 C k) p^r (1-p)^{x_i}

When we take the derivate of the likehood function we got:

l(p,x_i) = \sum_{i=1}^n [log (x_i +r-1 C k) + r log(p) + x_i log(1-p)]

And in order to estimate the likehood estimator for p we need to take the derivate from the last expression and we got:

\frac{dl(p,x_i)}{dp} = \sum_{i=1}^n \frac{r}{p} -\frac{x_i}{1-p}

And we can separete the sum and we got:

\frac{dl(p,x_i)}{dp} = \sum_{i=1}^n \frac{r}{p} -\sum_{i=1}^n \frac{x_i}{1-p}

Now we need to find the critical point setting equal to zero this derivate and we got:

\frac{dl(p,x_i)}{dp} = \sum_{i=1}^n \frac{r}{p} -\sum_{i=1}^n \frac{x_i}{1-p}=0

\sum_{i=1}^n \frac{r}{p} =\sum_{i=1}^n \frac{x_i}{1-p}

For the left and right part of the expression we just have this using the properties for a sum and taking in count that p is a fixed value:

\frac{nr}{p}= \frac{\sum_{i=1}^n x_i}{1-p}

Now we need to solve the value of \hat p from the last equation like this:

nr(1-p) = p \sum_{i=1}^n x_i

nr -nrp =p \sum_{i=1}^n x_i

p \sum_{i=1}^n x_i +nrp = nr

p[\sum_{i=1}^n x_i +nr]= nr

And if we solve for \hat p we got:

\hat p = \frac{nr}{\sum_{i=1}^n x_i +nr}

And if we divide numerator and denominator by n we got:

\hat p = \frac{r}{\bar x +r}

Since \bar x = \frac{\sum_{i=1}^n x_i}{n}

4 0
3 years ago
Simplify -1-2(8-6×2÷3)² is what
Mademuasel [1]

<em>Hope</em><em> </em><em>this</em><em> </em><em>will</em><em> </em><em>help</em><em> </em><em>u</em><em>.</em><em>.</em><em>✌</em><em />

3 0
3 years ago
Read 2 more answers
NERDS HELP ME !!!!!!!!
Ivahew [28]

Answer:

63 it's the closest

Step-by-step explanation:

5 0
3 years ago
Read 2 more answers
The ratio of the number of volleyball to the number of basketballs in the P.E room is 4:7 .there are 21 basketballs . How many v
densk [106]
Let volleyball be v and let basketball be b.

v : b = 4 : 7,      b = 21

v : 21 = 4 : 7

v/21 = 4/7

7*v = 4*21

v = 4*21/7

v = 4*3

v = 12

Volleyballs are 12

Hope this helps.
8 0
3 years ago
Other questions:
  • How many times does 12 go into 144
    13·2 answers
  • What is the greatest common factor of 42, 30, and 45​
    5·1 answer
  • Cards from an ordinary deck of 52 playing cards are turned face up one at a time. If the 1st card is an ace, or the 2nd a two, o
    9·1 answer
  • If a bottle rotates 140 degrees in 70 minutes, how many degrees will it rotate in 28 minutes
    8·2 answers
  • A cube has a side length of 7 in. <br><br> What is the volume of the cube?<br><br> ________ in3
    9·1 answer
  • Mark started walking to school at half past 9. christy arrived at school 15 minutes later .What time did she get to school​
    11·2 answers
  • Solve each system by substitution.
    6·1 answer
  • Find the measure of angle b
    10·1 answer
  • My last points to ask a question pls show work
    11·2 answers
  • Camillo needs 2,400 oz of jelly for the food challenge. If 48 oz of jelly cost $3.84, how much will Camillo spend on jelly? Expl
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!