Netnak bik

mail@pastecode.io avatar
unknown
pascal
2 years ago
1.0 kB
18
Indexable
Never

	Veuillez introduire N1 et N2:
	N1 :integer
	N2 :integer
	nombre :integer
	for n := N1 to N2 do
		begin
			{ Keep a copy of original number since 'n' will be divided by 10 every time }
			nombre := n
			is_good_number := 1
			{ We divide n by 10 increments to retrieve les chiffres one by one }
			while n >= 1 do
				begin
					{ Get chiffre of first position: ex 305, this gets 5 }
					chiffre := n - ( n DIV 10)*10
					{ We check that chiffre if divisible by the whole number stocked in 'nombre' variable }
					if chiffre != 0 then
						begin
						{ If we find only one chiffre that is not divisible then 'nombre' is not a good one }
							if nombre MOD chiffre != 0 then
								begin
									is_good_number := 0
									break;
								end
						end
					}
					{ We divide by 10 every time to move to next chiffre, 305 becomes 30 then 3 the "WHILE" loop would stop }
					n := n DIV 10
				end
			if is_good_number = 1 then
				begin
					print(nombre+" is a good number")
				end
		end