Not Yet Answered # Hardy-ramanujan number

G-Do 19 Discussion Starter ram.patil tsmc -3 pyTony 888 Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...

Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...

0

Hi ram.patil,

A Hardy-Ramanujan number is a number which can be expressed as the sum of two positive cubes in exactly two different ways. For example, 1729 is equal to the sum:

1^3+12^3

- or alternatively, to the sum:

9^3+10^3

- but not to any other sums of positive cubes. Let's think about a general strategy for collecting the first n of these numbers. You will need to store the numbers in an extendable data structure, such as a list. You will also need to keep trying to find numbers until you have found n of them, appending valid Hardy-Ramanujan numbers to the list as you go. To implement this, you could do a while loop which keeps looking for Hardy-Ramanujan numbers until the length of the list is n. Does that make sense?

To find the numbers themselves, you could always try the naive approach: beginning with 1729, check each number. Subtract successive integer cubes from the number and see if the difference is a cube. This could be represented by a for loop nested inside your while loop. During the for loop, keep track of every time the difference is a cube. If, when the for loop completes, the difference has been a cube only twice, you know that the number is a Hardy-Ramanujan number, and can be added to the list.

Hope this helps!

0

sir , i'm very glad to hear this from u ... i tried this method and i'm successful in getting the n such numbers.

0

Hi,

U can find the list of Ramanujan numbers in a given range using the following program,

Good luck.

*Edited 5 Years Ago by Ezzaral*: Snipped url. No promotion.

0

Do not high jack dead and buried threads, this is by the way Python not Java forum. Refer to by Python function I made for it today: http://www.daniweb.com/software-development/python/code/358014/1526449#post1526449, It is "slightly shorter" than "your" Java version.

This article has been dead for over six months. Start a new discussion instead.

Recommended Articles

Hi. Im using vb 2010. I want to dynamically add textboxes to my form by clicking on a button. I've google searched and so far this code worked:

```
Private Sub btn_addline_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_addline.Click
Dim txtB1 As New TextBox
Dim i
For i = ...
```