FoolForMath and asnaseer, I decided to give Project Euler 27 a try in C++ and ended up with this: http://nopaste.info/24739deb10.html See the attached image for a run time snapshot. Indeed, a brute force approach proved to be feasible.
Whats that?
Why is this so signifigant?
I thought you were solving euler numerical methods
@Inopeki: This is just for fun.
Oh ok. Is learning C++ fun? What can you use it for?
C++ is the most fun language I've ever learned. You can use it for almost anything, not to mention that it's an invaluable asset to be competent in it to succeed in today's software development industry (as well as research).
Is that so? I tried learning a "computer" language before, it failed miserably because it was so boring with all the codes and stuff, what makes C++ fun and what is the difference between it and C?
Maybe the way it is taught is what ends up making or breaking it for students these days. I see programming, in any language, as a fun process to give computers commands to perform whatever it is that you want them to; students get too caught up with the specific aspects of it and completely miss the big picture, much the same way they do with math. C++ is a modern version of C, and both follow two completely different problem-solving paradigms. C++ is an object oriented language whereas C is more of a scripting one. For that reason, C is often used over C++ whenever performance is of the essence.
So why isnt just C used, performance is always important.
Hey, Across :) I think you implemented brute-force approach?
Nowadays, the size of software is so gigantic (we're talking about millions of lines of code) that the use of a sequential programming language such as C would just end up confusing everyone and turning the software into an unintelligible spaghetti of code. That's the reason why an object oriented version of C, namely C++, was invented; thus far, object oriented programming has proven to be abstract enough to keep large projects tightly organized.
FFM, yes, that's a brute-force approach.
This site is better: http://ideone.com/UNwDO; as you don't need to upload the .exe file seperately.
Wow, very nice! I see it has a compiler implemented? This is so nifty! Thank you for that link!
You are welcome, and Yes, just to add it's from the same spoj.pl team.
if you like to take advantage of the subtleties in C/C++ for (int a = -999; a < 1000; a++) for (int b = -999; b < 1000; b++) { int cnt = 0, n=0 ; while (isPrime(f(a, b, n++))) cnt++; if (cnt > N) { A = a; B = b; N = cnt; } }
There is a scope of much improvement in the isprime() function too.
Nice! There you go! Yeah, I was never too good at optimizing. ^^
it's not optimizing. It's just writing code nobody can understand
This is not codegolf.
Hahahaha!
Join our real-time social learning platform and learn together with your friends!