Bonjours, j'aurai besoin d'aide pour ce problème : Une nombre de 6 chiffres commence à gauche par le chiffre 1. Si on transporte le 1 à droite, le nouveau nombr
Mathématiques
KEVNIII
Question
Bonjours, j'aurai besoin d'aide pour ce problème : Une nombre de 6 chiffres commence à gauche par le chiffre 1. Si on transporte le 1 à droite, le nouveau nombre ainsi obtenu est le triple du premier. Quel est le nombre initial ?
Merci à ceux qui m'aiderons.
Merci à ceux qui m'aiderons.
1 Réponse
-
1. Réponse caylus
Bonjour,
Le nombre est 142857.
DIM a AS INTEGER, b AS INTEGER, c AS INTEGER, d AS INTEGER, e AS INTEGER, f AS INTEGER
DIM w1 AS STRING, w2 AS STRING
DIM n1 AS LONG, n2 AS LONG
w1 = SPACE$(6)
MID$(w1, 1, 1) = "1"
FOR b = 0 TO 9
MID$(w1, 2, 1) = CHR$(48 + b)
FOR c = 0 TO 9
MID$(w1, 3, 1) = CHR$(48 + c)
FOR d = 0 TO 9
MID$(w1, 4, 1) = CHR$(48 + d)
FOR e = 0 TO 9
MID$(w1, 5, 1) = CHR$(48 + e)
FOR f = 0 TO 9
MID$(w1, 6, 1) = CHR$(48 + f)
n1 = VAL(w1)
w2 = MID$(w1, 2, 5) + MID$(w1, 1, 1)
n2 = VAL(w2)
IF n2 = 3 * n1 THEN
PRINT w1, w2
END IF
NEXT f
NEXT e
NEXT d
NEXT c
NEXT b
END