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.
on 2005-12-02 15:59
```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```
on 2005-12-02 16:32
```>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/...

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?```
on 2005-12-02 16:56
```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```
on 2005-12-04 00:25
```Dan Diebolt 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```
on 2005-12-04 00:29
```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 Gray II```
on 2005-12-04 00:33
```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```
on 2005-12-04 00:45
```James Edward Gray 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.```
on 2005-12-04 00:45
```Ah ha.  That's exactly what I was looking for.

Thanks!```
on 2005-12-04 01:17
```On 12/4/05, Nathan <nmorse@gmail.com> 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```
on 2005-12-04 01:38
```Paolo Capriotti wrote:
> On 12/4/05, Nathan <nmorse@gmail.com> 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```
on 2005-12-04 16:51
```On Dec 2, 2005, at 9:31 AM, Dan Diebolt 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 Gray II```
on 2005-12-04 17:40
```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 Gray II <james@grayproductions.net> wrote:  On Dec 2, 2005,
at 9:31 AM, Dan Diebolt 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 Gray II```
This topic is locked and can not be replied to.