Like Tree and YoMama, I solved it using Mersenne primes...
I don't claim credit for that- I just modified TreePuncher's code to try to illustrate what inline does.
Apologies, I wrote that purely automatically, seeing your contribution.
This is interesting, but this knowledge is kinda pure academic as you will be rarely messing with inline functions within your real projects.
I think this depends entirely on what you're doing- for any high-performance computing, you have to be aware of where you can cut out inefficiency, especially since Moore's law appears to be basically dead.
Of course, but what I mean is that you would rarely need to do it yourself: the compiler will interpret functions as inline when it's really needed. It's the same as overusing inline assembly: most of the modern compilers generate better assembly code than a programmer would, so you'd likely use it at the most crucial points of your program. But, of course, being capable of writing in assembly will definitely help you in your programmer's life. Besides, don't forget that inlining functions aren't just a magic wand, it can turn out to be negative, especially when you're working with classes in C++.
Well, Matt, if to talk about Mia`s code, it is bad. Do not write it on that way - making an array, putting in it all variables, so every time u program will go to RAM, it will call not a single int or long or whatever ur date type is, but it will go to an array, to the 4 bytes of its location, then it will move to the array`s numbers, change it... You just increasing time of prog. And well, that is kinda bm for someone who will read ur code.
Obviously Mia (and me) used an array instead of standard variables only because Spectre's task formulation suggested that. Aside of it, her code (as much as Tree's and mine) is pretty nice.
Of course, nobody would use arrays like we did, they exist for other purposes. But in fact you are not right saying that it will always spend more processor time. It is true for, say, Java, as the arrays are actually objects in Java. One bytecode instruction is used to access a "normal" variable (STORE var_idx or LOAD var_idx) and at least three to access an array value (ALOAD arr, PUSH idx, ALOAD or ASTORE). But it doesn't work like this in C: every variable, including an array element, is accessed by shifting from the base pointer (mov $value, -var_idx(%ebp) or mov -var_idx(%ebp), %eax).
And even more. In java you "do not give a fuck whats going on in ur RAM". But you must know how it works. If you take arrays, there is some unexpected stuff, which could lead you to overloading ur RAM or losing ur data. So, do not work with arrays THAT way.
And ofc you should care to minimize RAM using and time. If we talk about Mia`s code, you can simply divide by 2 RAM u are using and prog time by adding 2-3 symbols to the code. So, try to figure it out.
Well, the GC works very well nowadays, yet you should care about the memory. My experience tells that memory leaks happen more rarely in Java projects, but they are sometimes harder to locate and eliminate. As for the arrays, what unexpected stuff are you talking about? (sorry for picking on your words, but I just love Java and I'm always interested to discuss it
)
Yea Java is object oriented like PHP and C++. But it's one of the easiest to learn so I would say C++ looks harder.
Well, PHP's object orientation still looks like a diesel engine on a horse carriage...
Though, talking seriously, it is often handy.
Once you understand the main programming concept, you can easily start to write in any language. As for tricky particularities... Every language has a lot of them, you're just starting to feel and understand them with the experience.
I don't get what you're trying to say. As far as I got it, when you try to use something out of array range, the program will then fetch some unknown value from RAM. It can lead to some crazy output values, sure, but I don't know about losing data (correct me if I'm wrong and/or provide references for this statement).
You are right, it works this way in C and C++, but it isn't always like that. For example, an exception will be thrown in Java if you try to use an incorrect index.