Advertisement
LOVEGUN

Function FacPremier (Puis)

Mar 5th, 2021
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.67 KB | None | 0 0
  1. Function repet (c:Char;ch:String): String;
  2. Var
  3.   i,s: Integer;
  4. Begin
  5.   s := 0;
  6.   For i:=1 To Length(ch) Do
  7.     If ch[i]=c Then
  8.       s := s+1;
  9.   Str (s,ch);
  10.   repet := ch;
  11. End;
  12.  
  13. Function facteur (a:Integer): String;
  14. Var
  15.   i,e,x: Integer;
  16.   ch,ch1: String;
  17. Begin
  18.   i := 1;
  19.   ch1 := '';
  20.   Repeat
  21.     i := i+1;
  22.     If a Mod i =0 Then
  23.       Begin
  24.         a := a Div i;
  25.         Str(i,ch);
  26.         ch1 := ch1+ch+'*';
  27.         i := 1;
  28.       End;
  29.   Until (a Div i=0);
  30.   ch := '';
  31.   Repeat
  32.     ch := ch+ch1[1]+'_'+repet(ch1[1],ch1)+'*';
  33.     Val (repet(ch1[1],ch1),x,e);
  34.     Delete (ch1,1,x*2);
  35.   Until (ch1='');
  36.   Delete (ch,Length(ch),1);
  37.   facteur := ch;
  38. End;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement