Forum: Ruby Re: Weird Numbers (#57)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
simon.kroeger.ext (Guest)
on 2005-12-02 16:59
(Received via mailing list)
If I got I right, 70 would be such a number.
(I hope this is no spoiler)

divisors = [1, 2, 5, 7, 10, 14, 35]
sum = 74

no combination of the divisors adds up to 70

cheers

Simon
dandiebolt (Guest)
on 2005-12-02 17:32
(Received via mailing list)
>please give an example of such a number.

  70,836,4030,5830,7192,7912,9272,10430,10570,10792,10990,
           11410,11690,12110,12530,12670,13370,13510,13790,13930,14770,
           15610,15890,16030,16310,16730,16870,17272,17570,17990,18410,
           18830,18970,19390,19670

On-Line Encyclopedia of Integer Sequences!
  http://www.research.att.com/cgi-bin/access.cgi/as/...

  See Also:

  http://en.wikipedia.org/wiki/Weird_number
  http://mathworld.wolfram.com/WeirdNumber.html

  I would like to see an iterator in Ruby that took as one of its
arguments the On-Line Encyclopedia of Integer Sequences identifier
(A006037). And also an iterator in Ruby for the Combinatorial Object
Server:

  Combinatorial Object Server
  http://www.theory.cs.uvic.ca/~cos/cos.html

  Is that possible in Ruby?
dandiebolt (Guest)
on 2005-12-02 17:56
(Received via mailing list)
If you download the Mathematica notebook file for "Weird Number" from
this site:

  http://mathworld.wolfram.com/WeirdNumber.html

  You can convert the notebook file to pdf with this utility:

  http://library.wolfram.com/Explore/Publishing/NBtoPDF.jsp
nmorse (Guest)
on 2005-12-04 01:25
(Received via mailing list)
Dan D. wrote:
> >please give an example of such a number.
>
>   70,836,4030,5830,7192,7912,9272,10430,10570,10792,10990,
>            11410,11690,12110,12530,12670,13370,13510,13790,13930,14770,
>            15610,15890,16030,16310,16730,16870,17272,17570,17990,18410,
>            18830,18970,19390,19670
>

I can see how 70 is a "weird number" (divisors 2 + 5 + 7 + 10 + 14 + 35
= 74 and no subset adds up to 70), but can someone explain to me how
836 is considered "weird"?

2 + 11 + 19 + 22 + 38 + 209 = 301

Am I missing a divisor, because last time I checked 301 < 836.  When I
factor 836, I come up with 2 * 2 * 11 * 19 = 836.  Is this just one of
those cases where the internet is *wrong*?

Very confused,

-Nate
James G. (Guest)
on 2005-12-04 01:29
(Received via mailing list)
On Dec 3, 2005, at 5:22 PM, Nate wrote:

> When I factor 836, I come up with 2 * 2 * 11 * 19 = 836.

You're using the same factor twice in there.  That doesn't seem right...

James Edward G. II
SimonKroeger (Guest)
on 2005-12-04 01:33
(Received via mailing list)
Nate wrote:
>
> Very confused,
>
> -Nate

erm, if 2 is a divisor 836/2=418 should also be, hmm?

get some sleep :)

(and you missed some more: 1, 4, 38, 44, 76)

cheers

Simon
nmorse (Guest)
on 2005-12-04 01:45
(Received via mailing list)
James Edward G. II wrote:
> On Dec 3, 2005, at 5:22 PM, Nate wrote:
>
> > When I factor 836, I come up with 2 * 2 * 11 * 19 = 836.
>
> You're using the same factor twice in there.  That doesn't seem right...
>

True, the only factors of 836 are 2, 11, and 19.  I just meant to point
out that those are definitely the only factors because 2^2 * 11^1 *
19^1 = 836.  That said, does 836 have any other divisors besides 2, 11,
19, 22, 38, and 209?  I don't see how it could, but I would love to be
proved wrong.

Mostly I just want to know if the list posted previously is accurate or
not.
nmorse (Guest)
on 2005-12-04 01:45
(Received via mailing list)
Ah ha.  That's exactly what I was looking for.

Thanks!
p.capriotti (Guest)
on 2005-12-04 02:17
(Received via mailing list)
On 12/4/05, Nathan <removed_email_address@domain.invalid> wrote:
>
> True, the only factors of 836 are 2, 11, and 19.  I just meant to point
> out that those are definitely the only factors because 2^2 * 11^1 *
> 19^1 = 836.  That said, does 836 have any other divisors besides 2, 11,
> 19, 22, 38, and 209?  I don't see how it could, but I would love to be
> proved wrong.

irb(main):001:0> (1..836).select{|d| 836 % d == 0}
=> [1, 2, 4, 11, 19, 22, 38, 44, 76, 209, 418, 836]

> Mostly I just want to know if the list posted previously is accurate or
> not.

I think it is.

Paolo
nmorse (Guest)
on 2005-12-04 02:38
(Received via mailing list)
Paolo C. wrote:
> On 12/4/05, Nathan <removed_email_address@domain.invalid> wrote:
>
> irb(main):001:0> (1..836).select{|d| 836 % d == 0}
> => [1, 2, 4, 11, 19, 22, 38, 44, 76, 209, 418, 836]


Simon's right.  I definitely need more sleep.

Cheers,

-Nathan
James G. (Guest)
on 2005-12-04 17:51
(Received via mailing list)
On Dec 2, 2005, at 9:31 AM, Dan D. wrote:

>   I would like to see an iterator in Ruby that took as one of its
> arguments the On-Line Encyclopedia of Integer Sequences identifier
> (A006037). And also an iterator in Ruby for the Combinatorial
> Object Server:
>
>   Combinatorial Object Server
>   http://www.theory.cs.uvic.ca/~cos/cos.html
>
>   Is that possible in Ruby?

You bet.  Use the openuri library to grab the page, parse out what
you need, and yield results.  It's not even hard.  Give it a try and
you'll learn a lot about Ruby...  ;)

James Edward G. II
dandiebolt (Guest)
on 2005-12-04 18:40
(Received via mailing list)
I am not talking about screen scraping bits and pieces of information
off web sites but rather having a library of combinatorial iterators
wrapped up in classes: Combinations, Permutations, ... Debruijn
Sequences. Ruby blocks & yield statements would be a great way to
process each element of the combinatorial structure seperating the
problems of 1) generating the next element of combinatorial structure
from 2) processing each element of the combinatorial structure.

James Edward G. II <removed_email_address@domain.invalid> wrote:  On Dec 2, 
2005,
at 9:31 AM, Dan D. wrote:

> I would like to see an iterator in Ruby that took as one of its
> arguments the On-Line Encyclopedia of Integer Sequences identifier
> (A006037). And also an iterator in Ruby for the Combinatorial
> Object Server:
>
> Combinatorial Object Server
> http://www.theory.cs.uvic.ca/~cos/cos.html
>
> Is that possible in Ruby?

You bet. Use the openuri library to grab the page, parse out what
you need, and yield results. It's not even hard. Give it a try and
you'll learn a lot about Ruby... ;)

James Edward G. II
This topic is locked and can not be replied to.