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: 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 Integer have a setValue(int i), and is there a way of changing its value.
    ... With immutable keys, ... The alternative to immutability would ... Now, I assume that the second Integer added to the Map, will return an int value ... > this has the potential of being a security problem. ...
    (comp.lang.java.programmer)
  • Re: Help with sorting values in a TreeMap
    ... > the map is an AccountView object whose 'getKey' method returns the ... > I use TreeMap so that they sort nicely by the account number. ... When you construct a TreeMap with a Comparator, ... The objects that it would be comparing _are_ the keys that you described, ...
    (comp.lang.java.programmer)