Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jessica - Week 2 assignments #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

cheeyim
Copy link

@cheeyim cheeyim commented Nov 22, 2017

This PR will be reviewed by @MeiTzy222

@cheeyim cheeyim assigned saradesouza and MeiTzy222 and unassigned saradesouza Nov 22, 2017
if i**3 < limit:
cubedList.append(i)
return cubedList[-1] #returns the last number (highest cube) on cubedList. Can add .sort() to ensure list sorted lowest to highest.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like it! Clean and clear codes! Well done.

newLine+= (width*character) + "\n"
else:
newLine+= (character + " "*(width-2) + character) + "\n" #creates the hollow space in between two borders
return newLine

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, your solution looks a bit complicated to me. Wonder if it is possible to somewhat simplify it...


numberList=[] #creates an empty list 'numberList'
for i in range(max_number+1): #Stop is max_number +1 to ensure given number is also tested.
if _is_prime(i)==True: #calls _is_prime(number) function

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you have leveraged on the first function you built. Good!

for i in range (3,number,2): #checks if number is divisible by any number between 3 and number. 2 steps to skip even numbers. This can be improved with int(n**0.5) + 1 which I have not figured out yet.
if number%i == 0:
return False
return True #loop ends here if above conditions not met. We have a PRIME number!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Food for thought: Apart from tackling this by finding out what is a prime number, maybe it will be even more efficient if we can think about what is not a prime number...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants