A community for students.
Here's the question you clicked on:
 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)
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

maitre_kaio
 4 years ago
Best ResponseYou've already chosen the best response.1You probably want to use % (modulo), not / (integer division) For example: 13 / 5 = 2 and 13 % 5 = 3

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0Were 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.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0problem 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

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0problem 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.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.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.
Ask your own question
Sign UpFind more explanations on OpenStudy
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
 Engagement 19 Mad Hatter
 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.