Re: do u know ramanujan numbers algorithm



On Feb 29, 2:32 pm, Andreas Leitgeb <a...@xxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
Roedy Green <see_webs...@xxxxxxxxxxxxxxxxxxxx> wrote:
Just follow 4 for loops And test a^3+b^3 =c^3+d^3=a Number And print
those number.
you could improve slightly on that brute force approach this way:
1. you don't need to find all the permutations, just the ones where
a < b, a < c, and c < d (perhaps <=, I am not familiar with the exact
rules).

You could also iterate only over two variables and save the values
of a^3+b^3 as keys in a map. Before actually adding it to the map,
you'd check for it's previous existence in the map:  if it was
already there, you've found a solution.

Of course, when adding one, you need to store the value a as value
for key a^3+b^3, such that when you re-encounter the key, you also
know the previous a and (with simple math) b.

There's further potential for improvement by casually cleaning up
keys in the map that are small enough that re-encountering them
can be proven impossible. e.g. because it is smaller than current
a's cube.

Perhaps, it's even better to iterate the sum a+b in the other loop
and the difference (only till sign-change) in the inner loop, so you
do not have to decide on any maximum beforehand.

Has anyone paid the guy for a O(n^2) solution, yet?  ;-)

Pay and get the Solution The guy has not responded it means he just
ask for curiosity.

Any one else interested pay me $200 for the solution.

Bye
Sanny
.



Relevant Pages

  • Re: do u know ramanujan numbers algorithm
    ... You could also iterate only over two variables and save the values ... Before actually adding it to the map, ... keys in the map that are small enough that re-encountering them ... and the difference in the inner loop, ...
    (comp.lang.java.programmer)
  • Re: Why doesnt CMap have a copy constructor?
    ... keys, there isn't anything to stop you from iterating a map and retrieving all the keys. ... I agree with your point and meant no disrespect in offering a method to iterate the keys of a container. ...
    (microsoft.public.vc.mfc)
  • Re: How to compare hashes to find matching keys with conflicting values.
    ... I did read the perldoc info on map but I am> still confused on how it is being used here. ... I would have now way to link them back to the keys> from register as now they would be numerically ordered in the array instead> of being linked to the hostname key. ... The keys of %keys are sorted with it before it goes through the "map pipe". ...
    (perl.beginners)
  • RE: How to compare hashes to find matching keys with conflicting values.
    ... How to compare hashes to find matching keys with conflicting ... I see that we are creating an array called res however I ... I did read the perldoc info on map but I ... from register as now they would be numerically ordered in the array ...
    (perl.beginners)
  • Re: Why doesnt CMap have a copy constructor?
    ... there isn't anything to stop you from iterating a map and retrieving all ... the keys. ...
    (microsoft.public.vc.mfc)