-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: master
Are you sure you want to change the base?
Conversation
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. | ||
|
There was a problem hiding this comment.
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 | ||
|
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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! | ||
|
There was a problem hiding this comment.
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...
This PR will be reviewed by @MeiTzy222