Article View: comp.lang.c
Article #1157Re: BizFuss (was Re: Taming The Switch-Statement)
From: Lawrence D’Oliveiro
Date: Fri, 30 Oct 2026 08:27
Date: Fri, 30 Oct 2026 08:27
23 lines
2354 bytes
2354 bytes
On Thu, 29 Oct 2026 08:30:33 +0100, Rosario19 wrote:
> for(x=1;x<20;++x)
> {if(x%2==0) printf("%d divides by 2\n",x);
> if(x%3==0) printf("%d divides by 3\n",x);
> if(x%3!=0&&x%2!=0)
> printf("%d no divides (by 3 or 2)\n",x);
> }
Generalization I call “bizzfuzz” -- substitute whatever
factors and limit you want:
factors = (2, 3, 5, 7) # factors to be checked in order
limit = 200
for n in range(1, limit + 1) :
i = (list(n % factors[j] == 0 for j in range(len(factors))) + [True]).index(True)
if i < len(factors) :
print("%d is divisible by %d" % (n, factors[i]))
else :
print("%d is not divisible by any of (%s)" % (n, ", ".join(str(f) for f in factors)))
#end if
#end for
Technical Details
Message-ID:
<11c1kee$2lqi$2@dont-email.me>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<119qf6l$2rmg3$1@dont-email.me> <11ba02r$3pl5h$1@dont-email.me> <11bnfpm$i84l$1@dont-email.me> <11bng23$iblc$1@dont-email.me> <11bngj1$ifj5$1@dont-email.me> <11bnnbg$l7i1$1@dont-email.me> <11bntk0$nsbo$1@dont-email.me> <11bnvbq$olbj$1@dont-email.me> <11bo02r$otr5$1@dont-email.me> <11bo0ul$pbso$1@dont-email.me> <11bo1bc$phlr$1@dont-email.me> <tft5elp1q2ns7rhfp3rod862ks5ip3p0ms@4ax.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Lawrence D’Oliveiro <ldo@nz.invalid> Newsgroups: comp.lang.c Subject: Re: BizFuss (was Re: Taming The Switch-Statement) Date: Fri, 30 Oct 2026 08:27:59 -0000 (UTC) Organization: A noiseless patient Spider Lines: 23 Message-ID: <11c1kee$2lqi$2@dont-email.me> References: <119qf6l$2rmg3$1@dont-email.me> <11ba02r$3pl5h$1@dont-email.me> <11bnfpm$i84l$1@dont-email.me> <11bng23$iblc$1@dont-email.me> <11bngj1$ifj5$1@dont-email.me> <11bnnbg$l7i1$1@dont-email.me> <11bntk0$nsbo$1@dont-email.me> <11bnvbq$olbj$1@dont-email.me> <11bo02r$otr5$1@dont-email.me> <11bo0ul$pbso$1@dont-email.me> <11bo1bc$phlr$1@dont-email.me> <tft5elp1q2ns7rhfp3rod862ks5ip3p0ms@4ax.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Fri, 30 Oct 2026 08:27:59 +0000 (UTC) Injection-Info: dont-email.me; logging-data="87890"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX188Omdf1PeIaV9GJnYnmScL"; posting-host="a2d4bf737ef4dcecc3ecbe7a7a4a744c" User-Agent: Pan/0.165 (Kostiantynivka) Cancel-Lock: sha1:eiczfCpM5RLMX9bItp2CukarUrA= sha256:kwyzvQJQaF2DgH0VmnGgfkMWNgR2tKJ9Ym8JkQK48DU= sha1:a3SO7E7OInYxpqvf+Ebeo39bbVg= sha256:ejdg1D0RZur+ba6EvUD7p/qqLE2XDrhlpOd2yrIBmXY=