| Christian Hoffmann on Thu, 26 Sep 2013 13:47:55 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| function result vector ? |
I have the following problem with a vector as a function result:
(Trying to split a prime of form 4k+1 into two squares)
twosquares(n) = \
local (r, p, q);\
{\
r=floor(sqrt(n));\
v=vector(2);\
v=[-1,0];\
forstep(p=r,0,-1, if(issquare(n-p^2,&q),{v=[p,q]; print(v); break}));\
\\forstep(p=r,0,-1, if(issquare(n-p^2,&q), break;));\
v=[p,q];\
print(p." ",q)
return(v)
}
twosquares(17)
0 1
%50 = [0, 1]
instead of [4, 1] . ( 17 = 4^2 + 1^2 )
Christian
PS: Is there a rigorous definition of Pari syntax?
--
Christian W. Hoffmann,
CH - 8915 Hausen am Albis, Switzerland
Rigiblickstrasse 15 b, Tel.+41-44-7640853
(!! c-w.hoffmann@sunrise.ch, <will be eliminated in the near future,
instead Bitte nicht mehr benutzen !!, stattdessen: >)
mailto: christian@echoffmann.ch
home: www.echoffmann.ch