Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!news2.arglkargh.de!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Readability part I - code Date: Fri, 10 Jul 2015 10:49:53 -0700 Organization: None to speak of Lines: 27 Message-ID: References: <874mnojjn4.fsf@kst-u.example.com> <4709b760-ddcf-490c-9f53-acc78cb171ac@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="1855"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/OaRDlRdIuLvzoDlKbBzbG" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:2El9L34dZQeD17NwY5cNRDKHZRI= sha1:TLbYnxo7UZWqsu3RFa/pT3T2M60= Xref: csiph.com comp.lang.c:65152 Richard Heathfield writes: > On 10/07/15 15:35, Tim Rentsch wrote: > Um, I know this has nothing to do with the thread, but, uh... > >> >> and I prefer this >> >> int >> is_prime( int n ){ >> int i; >> for( i = 2; i < n; i++ ){ >> if( n%i == 0 ) return 0; >> } >> return 1; >> } > > ...how sure are you about that function? It is saying that all negative > integers are prime, as are 0, 1, and 2... and *everything else* is > non-prime. No, it works correctly for integers greater than 1 (I just tried it). -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"