Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {https://cdn.discordapp.com/attachments/833273071325675531/835868501952036865/20210425_142227.jpg}
- Program exercice2;
- Uses Wincrt;
- Var
- n: longint;
- Procedure saisie (Var n:Longint);
- Begin
- Writeln ('Saisir N: ');
- Readln (n);
- End;
- Function puis (x:longint;n:longint): Longint;
- Var
- s,i: longint;
- Begin
- s := 1;
- For i:=1 To n Do
- s := s*x;
- puis := s;
- End;
- Function somme (ch:String;n:longint): Longint;
- Var
- s,i,x,e: longint;
- Begin
- s := 0;
- For i:=1 To n Do
- Begin
- Val (ch[i],x,e);
- s := s+puis(x,n);
- End;
- somme := s;
- End;
- Function convert (n,b:longint): longint;
- Var
- s,e:longint;
- ch,ch1:string;
- Begin
- ch:='';
- Repeat
- str (n mod b,ch1);
- ch:=ch1+ch;
- n:=n div b;
- Until (n=0);
- val (ch,s,e);
- convert:=s;
- End;
- Procedure traitement (n:Longint);
- Var
- ch: String;
- Begin
- Str (n,ch);
- If convert(somme(ch,Length(ch)),Length(ch))=n Then
- Writeln ('C''est un nombre remarquable')
- Else
- Writeln ('Ce n''est pas un nombre remarquable');
- End;
- Begin
- saisie (n);
- traitement (n);
- End.
Add Comment
Please, Sign In to add comment