Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
3
Task/Repeat-a-string/PARI-GP/repeat-a-string-1.parigp
Normal file
3
Task/Repeat-a-string/PARI-GP/repeat-a-string-1.parigp
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
repeat(s,n)={
|
||||
if(n, Str(repeat(s, n-1), s), "")
|
||||
};
|
||||
1
Task/Repeat-a-string/PARI-GP/repeat-a-string-2.parigp
Normal file
1
Task/Repeat-a-string/PARI-GP/repeat-a-string-2.parigp
Normal file
|
|
@ -0,0 +1 @@
|
|||
repeat(s,n)=concat(vector(n,i, s));
|
||||
8
Task/Repeat-a-string/PARI-GP/repeat-a-string-3.parigp
Normal file
8
Task/Repeat-a-string/PARI-GP/repeat-a-string-3.parigp
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
repeat(s,n)={
|
||||
if(n<4, return(concat(vector(n,i, s))));
|
||||
if(n%2,
|
||||
Str(repeat(Str(s,s),n\2),s)
|
||||
,
|
||||
repeat(Str(s,s),n\2)
|
||||
);
|
||||
}
|
||||
20
Task/Repeat-a-string/PARI-GP/repeat-a-string-4.parigp
Normal file
20
Task/Repeat-a-string/PARI-GP/repeat-a-string-4.parigp
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
\\ Repeat a string str the specified number of times ntimes and return composed string.
|
||||
\\ 3/3/2016 aev
|
||||
srepeat(str,ntimes)={
|
||||
my(srez=str,nt=ntimes-1);
|
||||
if(ntimes<1||#str==0,return(""));
|
||||
if(ntimes==1,return(str));
|
||||
for(i=1,nt, srez=concat(srez,str));
|
||||
return(srez);
|
||||
}
|
||||
|
||||
{
|
||||
\\ TESTS
|
||||
print(" *** Testing srepeat:");
|
||||
print("1.",srepeat("a",5));
|
||||
print("2.",srepeat("ab",5));
|
||||
print("3.",srepeat("c",1));
|
||||
print("4.|",srepeat("d",0),"|");
|
||||
print("5.|",srepeat("",5),"|");
|
||||
print1("6."); for(i=1,10000000, srepeat("e",10));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue