A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 4 years ago

I'm having trouble with problem 2 in problem set 1.so far i did this & getting an error:: from math import * count = 0 i = 1 limitnum = raw_input('Enter the limit of the range') for i in range(2,limitnum): if limitnum/i == 0: break; else: count= count+ log(i+1) i = i + 1 print log(i)

  • This Question is Closed
  1. maitre_kaio
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    You probably want to use % (modulo), not / (integer division) For example: 13 / 5 = 2 and 13 % 5 = 3

  2. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Were you able to solve Problem 1 successfully? If so, please post the code. Problem 2 builds on Problem 1 and requires only a slight modification.

  3. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    problem 1: prime = 0 number = 1 while prime < 1000: number = number + 1 # starting from 2 # testing if the number is prime or not divisor = 2 numberIsPrime = True while divisor*divisor <= number: if number % divisor == 0: numberIsPrime = False break divisor = divisor + 1 # found one? if numberIsPrime: prime = prime + 1 print number

  4. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    problem 2 is giving an error:File "C:\Python25\ps1b.py", line 11, in <module> for i in range(2,limitnum): TypeError: range() integer end argument expected, got str. still can't slove.

  5. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    @maitre_kaio:thanx for highlighting the logical error,but i think it's giving me a syntax error.isn't it??i have post it above.

  6. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.