Mathématiques

Question

Bonjour, f est une fonction sur N telle que
f(1)=2
f(2)=3
et
f(f(f(n)))=n+2 si n est pair, n+4 si n est impair.
Trouver la valeur de f(777) et justifier, svp.
merci

1 Réponse

  • Réponse :

    Bonsoir,

    Explications étape par étape

    f(1)=2

    f(2)=f(f(1))=3

    f(f(f(1))=5

    A la 582ème itération,

    f(777)=390

    f(390)=779

    DIM a AS LONG, b AS LONG, c AS LONG, x AS LONG, i AS LONG

    a = 1

    b = 2

    c = 3

    i = 0

    DO WHILE a <> 777

       IF a MOD 2 = 0 THEN

           x = a + 2

       ELSE

           x = a + 4

       END IF

       i = i + 1

       PRINT i, x

       a = b

       b = c

       c = x

    LOOP

    PRINT "a="; a

    PRINT "b="; b

    PRINT "c="; c

    PRINT "x="; x

    PRINT "i="; i

    END

Autres questions