Deutsch   English   Français   Italiano  
<6336b936$0$5132$426a74cc@news.free.fr>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.mixmin.net!proxad.net!feeder1-2.proxad.net!cleanfeed1-b.proxad.net!nnrp1-1.free.fr!not-for-mail
Date: Fri, 30 Sep 2022 11:39:02 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.11.0
Subject: Re: Que fait ce programme ?
Content-Language: fr
Newsgroups: fr.sci.maths,fr.comp.lang.python
References: <63367bdd$0$25804$426a74cc@news.free.fr>
From: Michel Talon <talon@niobe.lpthe.jussieu.fr>
In-Reply-To: <63367bdd$0$25804$426a74cc@news.free.fr>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 28
Message-ID: <6336b936$0$5132$426a74cc@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 30 Sep 2022 11:39:02 CEST
NNTP-Posting-Host: 88.161.173.7
X-Trace: 1664530742 news-2.free.fr 5132 88.161.173.7:30236
X-Complaints-To: abuse@proxad.net
Bytes: 1512

Le 30/09/2022 à 07:17, ast a écrit :
> Devinette: Que retourne cette petite fonction python
> 
> (m et n sont 2 entiers naturels)
> 
> 
> def f(m, n):
>    while n:
>      m, n = m ^ n, (m & n) << 1
>    return m
> 
> 
> pour ceux qui ne connaissent pas python
> 
> "while n" c'est "pendant que n est non nul"
> 
> ^ est l'opérateur "ou exclusif" bit à bit
> & est le "et" bit à bit
> << 1 décalage à gauche bit à bit et ajout d'un 0 à droite
> 
> a, b = c, d  affectation simultanée a <- c et b <- d
> 

m+n


-- 
Michel Talon