I've just ignored this 3 problems (out of 9) in my final today and I wonder someone could help me to solve these problems so I can understand how to do it. 1/ Suppose we have a job that will take 20 hours to complete, and requires the use of a special (and expensive!) type of battery. It is known from exhaustive testing that the probability one of these batteries will wear out in (exactly) one hour is 0 .1, in two hours is 0.4, in three hours is 0.3 and in four hours is 0.2. For each 5 =< n =< 20 , let Pn denote the probability that exactly n batteries will be required to finish the job. Write a program that uses simulation to approximate the probabilities Pn . Perform a large number of simulated jobs, each time counting how many batteries were needed to complete the necessary 20 hours of work. Whenever a new battery is required, use a random number to determine how long it will last. Assume that as soon as a battery wears out, it is immediately replaced with a new one. Approximate each Pn as the fraction of trials when exactly n batteries were required to finish the job. 2/ The goal is to write a program that will determine whether or not a given number is prime. Let N and D be positive integers. D is called a divisor of N if there is a positive integer Q such that N = QD. An integer N >= 2 is called a prime number (or simply prime) if it has no divisors other than 1 and N itself. Equivalently, N is prime if it is not the product of two smaller positive integers. (For example, N = 10 is not prime, since10 = 2*5 , but N = 13 is prime.) To determine whether or not an integer N is prime, we could successively test each of the numbers P = 2,3, ... ,N - 1, stopping if we encounter a divisor. But note that if an even number is a divisor of N, then so is P = 2 . Thus, we can restrict our testing to the number 2, and to the odd integers that are less than N . Moreover, we can stop at sqrt(N) , since if there is a divisor that is greater than sqrt(N), then there must also be one that is less. Write a program that will take an integer N as input, and determine whether or not it is prime. Your program should use a while loop to search for a nontrivial divisor of N, successively testing the numbers P = 2,3,5,7, , up to the largest odd integer less than or equal to N , if necessary. (The MATLAB function rem will be useful here.) If a divisor is found, the loop should immediately terminate. In this case the program should report that N is not prime, and print this divisor. If no divisor is found, the program should report that N is prime. Test your program on the integers: N = 3,358,247, N = 193,707,721, N = 2,147,483,647, and N = 3,524,084,471. I really appreciate your help

0 |

12/12/2013 10:50:20 AM

"dazazivn" wrote in message <l8c4dc$1nb$1@newscl01ah.mathworks.com>... > I've just ignored this 3 problems (out of 9) in my final today and I wonder someone could help me to solve these problems so I can understand how to do it. > > 1/ > Suppose we have a job that will take 20 hours to complete, and requires the use of a special (and expensive!) type of battery. It is known from exhaustive testing that the probability one of these batteries will wear out in (exactly) one hour is 0 .1, in two hours is 0.4, in three hours is 0.3 and in four hours is 0.2. For each 5 =< n =< 20 , let Pn denote the probability that exactly n batteries will be required to finish the job. Write a program that uses simulation to approximate the probabilities Pn . Perform a large number of simulated jobs, each time counting how many batteries were needed to complete the necessary 20 hours of work. Whenever a new battery is required, use a random number to determine how long it will last. Assume that as soon as a battery wears out, it is immediately replaced with a new one. Approximate each Pn as the fraction of trials when exactly n batteries > were required to finish the job. > > 2/ > The goal is to write a program that will determine whether or not a given number is prime. > > Let N and D be positive integers. D is called a divisor of N if there is a positive integer Q such that N = QD. An integer N >= 2 is called a prime number (or simply prime) if it has no divisors other than 1 and N itself. Equivalently, N is prime if it is not the product of two smaller positive integers. (For example, N = 10 is not prime, since10 = 2*5 , but N = 13 is prime.) > To determine whether or not an integer N is prime, we could successively test each of the > numbers P = 2,3, ... ,N - 1, stopping if we encounter a divisor. But note that if an even number is a divisor of N, then so is P = 2 . Thus, we can restrict our testing to the number 2, and to the odd integers that are less than N . Moreover, we can stop at sqrt(N) , since if there is a divisor that is greater than sqrt(N), then there must also be one that is less. > > Write a program that will take an integer N as input, and determine whether or not it is prime. > > Your program should use a while loop to search for a nontrivial divisor of N, successively testing the numbers P = 2,3,5,7, , up to the largest odd integer less than or equal to N , if necessary. (The MATLAB function rem will be useful here.) If a divisor is found, the loop should immediately terminate. In this case the program should report that N is not prime, and print this divisor. If no divisor is found, the program should report that N is prime. > Test your program on the integers: N = 3,358,247, N = 193,707,721, N = 2,147,483,647, and N = 3,524,084,471. > > I really appreciate your help Making some effort of your own is what teaches you how to solve these problems. They are not at all difficult, so why not try them? Then when something does not work, you will get a far more accepting response if you show what you tried and then ask a question. Just posting the questions and asking for help gets you nothing, except to teach you that sometimes you can con someone into doing your work for you. Anyway, what reason do we have to believe that we would not just be solving a problem on a take home test for you? How do we know that you are not telling us a lie? So make an effort. You might surprise yourself.

0 |

12/12/2013 2:52:27 PM

If you don't want to help, then don't spend time to read about my questions. Whether you or anyone help me or not, it's not an important thing to me since the final is the past. And please don't think about me like that, what if I'm not a college student? What if I didn't mention that these problems were on my final? The way you react make me assume that you were doing something like that in the past. That's why now you think/assume everybody is just the same with you. Sorry, if you don't feel this topic is appropriate, just delete it. "John D'Errico" <woodchips@rochester.rr.com> wrote in message <l8cijb$n4g$1@newscl01ah.mathworks.com>... > "dazazivn" wrote in message <l8c4dc$1nb$1@newscl01ah.mathworks.com>... > > I've just ignored this 3 problems (out of 9) in my final today and I wonder someone could help me to solve these problems so I can understand how to do it. > > > > 1/ > > Suppose we have a job that will take 20 hours to complete, and requires the use of a special (and expensive!) type of battery. It is known from exhaustive testing that the probability one of these batteries will wear out in (exactly) one hour is 0 .1, in two hours is 0.4, in three hours is 0.3 and in four hours is 0.2. For each 5 =< n =< 20 , let Pn denote the probability that exactly n batteries will be required to finish the job. Write a program that uses simulation to approximate the probabilities Pn . Perform a large number of simulated jobs, each time counting how many batteries were needed to complete the necessary 20 hours of work. Whenever a new battery is required, use a random number to determine how long it will last. Assume that as soon as a battery wears out, it is immediately replaced with a new one. Approximate each Pn as the fraction of trials when exactly n batteries > > were required to finish the job. > > > > 2/ > > The goal is to write a program that will determine whether or not a given number is prime. > > > > Let N and D be positive integers. D is called a divisor of N if there is a positive integer Q such that N = QD. An integer N >= 2 is called a prime number (or simply prime) if it has no divisors other than 1 and N itself. Equivalently, N is prime if it is not the product of two smaller positive integers. (For example, N = 10 is not prime, since10 = 2*5 , but N = 13 is prime.) > > To determine whether or not an integer N is prime, we could successively test each of the > > numbers P = 2,3, ... ,N - 1, stopping if we encounter a divisor. But note that if an even number is a divisor of N, then so is P = 2 . Thus, we can restrict our testing to the number 2, and to the odd integers that are less than N . Moreover, we can stop at sqrt(N) , since if there is a divisor that is greater than sqrt(N), then there must also be one that is less. > > > > Write a program that will take an integer N as input, and determine whether or not it is prime. > > > > Your program should use a while loop to search for a nontrivial divisor of N, successively testing the numbers P = 2,3,5,7, , up to the largest odd integer less than or equal to N , if necessary. (The MATLAB function rem will be useful here.) If a divisor is found, the loop should immediately terminate. In this case the program should report that N is not prime, and print this divisor. If no divisor is found, the program should report that N is prime. > > Test your program on the integers: N = 3,358,247, N = 193,707,721, N = 2,147,483,647, and N = 3,524,084,471. > > > > I really appreciate your help > > Making some effort of your own is what teaches you how > to solve these problems. They are not at all difficult, so > why not try them? > > Then when something does not work, you will get a far > more accepting response if you show what you tried and > then ask a question. > > Just posting the questions and asking for help gets you > nothing, except to teach you that sometimes you can > con someone into doing your work for you. Anyway, > what reason do we have to believe that we would not > just be solving a problem on a take home test for you? > How do we know that you are not telling us a lie? > > So make an effort. You might surprise yourself.

0 |

12/12/2013 3:33:07 PM

"dazazivn" wrote in message <l8ckvj$276$1@newscl01ah.mathworks.com>... > If you don't want to help, then don't spend time to read about my questions. Whether you or anyone help me or not, it's not an important thing to me since the final is the past. And please don't think about me like that, what if I'm not a college student? What if I didn't mention that these problems were on my final? > > The way you react make me assume that you were doing something like that in the past. That's why now you think/assume everybody is just the same with you. Sorry, if you don't feel this topic is appropriate, just delete it. You've just ticked-off one of the most prolific responders of this newsgroup. If you do a search, you will find John has provided emensely valuable help to many, many people over the years. He has also posted many valuable submissions to the FEX. If you read his post carefully, you will see he didn't accuse you of anything. He simply asked some very obvious questiions. You are the one who made the accusations in your response above. > > "John D'Errico" <woodchips@rochester.rr.com> wrote in message <l8cijb$n4g$1@newscl01ah.mathworks.com>... > > "dazazivn" wrote in message <l8c4dc$1nb$1@newscl01ah.mathworks.com>... > > > I've just ignored this 3 problems (out of 9) in my final today and I wonder ....snip... > > > I really appreciate your help > > > > Making some effort of your own is what teaches you how > > to solve these problems. They are not at all difficult, so > > why not try them? > > > > Then when something does not work, you will get a far > > more accepting response if you show what you tried and > > then ask a question. > > > > Just posting the questions and asking for help gets you > > nothing, except to teach you that sometimes you can > > con someone into doing your work for you. Anyway, > > what reason do we have to believe that we would not > > just be solving a problem on a take home test for you? > > How do we know that you are not telling us a lie? > > > > So make an effort. You might surprise yourself.

0 |

12/12/2013 3:55:08 PM

"dazazivn" wrote in message <l8ckvj$276$1@newscl01ah.mathworks.com>... > If you don't want to help, then don't spend time to read about my questions. Whether you or anyone help me or not, it's not an important thing to me since the final is the past. And please don't think about me like that, what if I'm not a college student? What if I didn't mention that these problems were on my final? > Regardless of whether you mentioned where they were or not, you have still made no effort. Making an effort of your own is what will help you. Giving you an easy answer does nothing for you if you have tried nothing to start.

0 |

12/12/2013 5:34:08 PM