# ETOOBUSY π minimal blogging for the impatient

# Killing spiders - a fresh look on Chowla Numbers

**TL;DR**

Donβt burn the house to kill a spider.

In previous post PWC109 - Chowla Numbers I gave a *very inefficient*
solution to the challenge:

```
sub gcd { my ($A, $B) = @_; ($A, $B) = ($B % $A, $A) while $A; return $B }
sub chowla_number ($n) { sum(grep { gcd($n, $_) == $_ } 2 .. $n - 1) // 0 }
```

Well, it was *more* inefficient than I was thinking at the time. And I
am lucky that `Colin Crain`

reviews all the submissions and provides
fruitful comments on the solutions (Colin Crain βΊ Perl Weekly Review #109).

Nowβ¦ emojis are me, reading through the post andβ¦ taking action:

The most basic way to determine whether a number is a divisor of another number is to try the division and see it there is any remainder.

π§ πͺ π

[β¦] Flavio has provided us with something completely different: using a greatest common divisor routine to vet the divisor candidates.

π€ π± π€―

I find this somewhat analogous to burning down the house to kill a spider, but it gets the job done and certainly made me think.

π π

```
sub chowla_number ($n) { sum(grep { !($n % $_) } 2 .. $n - 1) // 0 }
```

π€

So there you have it: **feedback is key**! Thanks Colin π