![]() |
|
|
#2443 | |
|
"Forget I exist"
Jul 2009
Dumbassville
838410 Posts |
Quote:
|
|
|
|
|
|
|
#2444 |
|
Aug 2006
3×1,993 Posts |
You could do factor(192384)[1,1] to get the smallest prime factor, factor(192384)[2,1] to get the second (if it exists), and so forth.
|
|
|
|
|
|
#2445 |
|
"Forget I exist"
Jul 2009
Dumbassville
203008 Posts |
I just want people to know that if some of the codes I post elsewhere don't seem correct I now have both 2.5.3 and 2.7.0 and probably another. I love some of these new add-on's to existing functions etc.
|
|
|
|
|
|
#2446 |
|
"Forget I exist"
Jul 2009
Dumbassville
26·131 Posts |
yes I made another try at aligen that I would hope is at least more inclusive than previous versions:
Code:
aligentry(n)={c=[];
forpart(x=n-1,
if(#x==#vecsort(x,,8) && numdiv(x[1]*x[#x])-2==#x && setminus(divisors(x[1]*x[#x]),Vec(x))==[1,x[1]*x[#x]],
c=concat(c,x[1]*x[#x])
)
,a=[2,n-1])
;c
}
|
|
|
|
|
|
#2447 | ||
|
Aug 2006
3·1,993 Posts |
science_man, I don't understand what that function is trying to do. But looking back through this thread using the search term "aligen" I found this exchange, and maybe a better answer to it will help you:
Quote:
Quote:
Code:
partNo1(n)={
partitions(n, [2, n])
};
Code:
distinctPartNo1(n)={
select(v->#v==#Set(v), partitions(n, [2, n]))
};
Code:
distinctPartNo1(n)={
my(d=sqrtint(2*n+2));
if(d*(d+1)/2 > 2*n+2, d--);
select(v->#v==#Set(v), partitions(n, [2, n], d))
};
|
||
|
|
|
|
|
#2448 | |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
Quote:
|
|
|
|
|
|
|
#2449 | |
|
Aug 2006
597910 Posts |
Quote:
|
|
|
|
|
|
|
#2450 | |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
Quote:
Code:
floor(solve(y=1,n-1,sum(z=1,floor(y),z)-(n-1))) |
|
|
|
|
|
|
#2451 |
|
Aug 2006
3×1,993 Posts |
Something like that, yes. Actually I'm a bit surprised solve() doesn't choke on that, wouldn't it be better to use something like
solve(y=1,n-1, y*(y+1)/2-n+1)\1 to remove the flat parts. I guess it doesn't really matter -- this is outside the hot path so speed is nearly irrelevant. |
|
|
|
|
|
#2452 | |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
Quote:
|
|
|
|
|
|
|
#2453 |
|
Aug 2006
3·1,993 Posts |
Your original code:
Code:
aligentry0(n)={c=[];
forpart(x=n-1,
if(#x==#vecsort(x,,8) && numdiv(x[1]*x[#x])-2==#x && setminus(divisors(x[1]*x[#x]),Vec(x))==[1,x[1]*x[#x]],
c=concat(c,x[1]*x[#x])
)
,a=[2,n-1])
;c
};
Code:
aligentry1(n)={
my(c=List());
forpart(x=n-1,
if(#x==#Set(x) && numdiv(x[1]*x[#x])-2==#x && setminus(divisors(x[1]*x[#x]),Vec(x))==[1,x[1]*x[#x]],
listput(c, x[1]*x[#x])
)
,
[2,n-2]
,
solve(y=1,n-1, y*(y+1)/2-n+1)\1
);
Vec(c)
};
|
|
|
|
![]() |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Why do I sometimes see all the <> formatting commands when I quote or edit? | cheesehead | Forum Feedback | 3 | 2013-05-25 12:56 |
| Passing commands to PARI on Windows | James Heinrich | Software | 2 | 2012-05-13 19:19 |
| Ubiquity commands | Mini-Geek | Aliquot Sequences | 1 | 2009-09-22 19:33 |
| 64-bit Pari? | CRGreathouse | Software | 2 | 2009-03-13 04:22 |
| Are these commands correct? | jasong | Linux | 2 | 2007-10-18 23:40 |