Program S1;
Var
n : longint;
//***************************
Procedure saisie(Var n:longint);
Begin
Repeat
writeln('donner n');
readln(n);
Until n>=9 ;
End;
//***************************
Function divisible(Var n:longint) : integer;
Var
ch : string;
e,x,i,s : integer;
Begin
str(n,ch);
val(ch[1],x,e);
s := x;
For i:=2 To length(ch) Do
Begin
val(ch[i],x,e) ;
s := s+x;
If s>=9 Then
Repeat
s := s-9;
Until s<9;
End;
divisible := s;
End;
//***************************
Begin
saisie(n);
If divisible(n)=0 Then
writeln(n,' est divisible par car ',n,'=9*',n Div 9)
Else writeln(n,' n''est pas divisible par 9 ');
End.
Inscription à :
Publier les commentaires (Atom)