Our server costs ~$56 per month to run. Please consider donating or becoming a Patron to help keep the site running. Help us gain new members by following us on Twitter and liking our page on Facebook!
Current time: November 4, 2026, 9:00 pm

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Project Euler
#11
RE: Project Euler
(July 3, 2016 at 6:20 am)SteelCurtain Wrote: Sure!

To be clear, I didn't actually loop through every number. I skipped evens, and I didn't check for factors after 1/3 of the number I was checking.

Ok, so it looks like you don't really need one then. I just reread your previous post and realized you already did solve that.

I think though it's a similar thing with the triangle numbers, but it's been a while now so can't remember exactly what I did.
Reply
#12
RE: Project Euler
(July 3, 2016 at 6:27 am)Irrational Wrote:
(July 3, 2016 at 6:20 am)SteelCurtain Wrote: Sure!

To be clear, I didn't actually loop through every number. I skipped evens, and I didn't check for factors after 1/3 of the number I was checking.

Ok, so it looks like you don't really need one then. I just reread your previous post and realized you already did solve that.

I think though it's a similar thing with the triangle numbers, but it's been a while now so can't remember exactly what I did.

I just remembered what I did. Are you doing the same for what you did with the prime summation problem, and then ... depending on whether the number you're checking is a perfect ... or not?
Reply
#13
RE: Project Euler
I really like these problems, I've been looking for a website like this for ages!

Also, I've never used Python before, but looking at its syntax, I may learn in just for these problems. It just looks so neat!
Reply
#14
RE: Project Euler
(July 3, 2016 at 6:37 am)A Handmaid Wrote: I really like these problems, I've been looking for a website like this for ages!

Also, I've never used Python before, but looking at its syntax, I may learn in just for these problems. It just looks so neat!

Yeah, the only thing thus far I've noticed is a problem with Python that other programming languages I've tried do not have is that you can't declare a variable without initializing it. Or at least I don't know of a way to do so.
Reply
#15
RE: Project Euler
Wait, you can declare variables in Python without initializing them.

Code:
def main(): a = 5 print(a) main()

In other languages you'll at least have to declare the variable type, whereas Python will determine the variable type automatically. At least the packaged compiler/shell (IDLE) will.
Reply
#16
RE: Project Euler
(July 3, 2016 at 7:44 am)SteelCurtain Wrote: Wait, you can declare variables in Python without initializing them.

Code:
def main():    a = 5    print(a) main()

In other languages you'll at least have to declare the variable type, whereas Python will determine the variable type automatically. At least the packaged compiler/shell (IDLE) will.

Sorry, but can you elaborate on what you did here to show that this is possible? All I see is that you created a procedure that prints the value of 5 and then called it.
Reply
#17
RE: Project Euler
Well, why would you need uninitialized values?

I can't find a good reason for a language to have one.
Reply
#18
RE: Project Euler
It was just an example of defining a variable 'a' without initializing it first with Python.

For example, in C++, this same code would look like:

Code:
#include <iostream> using namespace std; int main() { int a; a = 5; //you could technically combine these two lines into 'int a = 5;' cout << a << endl; return 0; }
Reply
#19
RE: Project Euler
(July 3, 2016 at 8:02 am)A Handmaid Wrote: Well, why would you need uninitialized values?

I can't find a good reason for a language to have one.

I'll include an example code if I remember what it was I was struggling with that made me wish python would let me define variables without assigning values.
Reply
#20
RE: Project Euler
Ahh, I see what you mean.

You want to just initialize variables.

I think Python only allows you to do that with lists and tuples.
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  [Euler] Need clarification shadowdancer 11 6532 November 22, 2011 at 2:17 am
Last Post: shadowdancer



Users browsing this thread: 1 Guest(s)