![]() |
|
|
#2333 |
|
Aug 2006
3×1,993 Posts |
It's so much nicer if you format the code!
Code:
{b=2;
forprime(p=2,2281,
for(y=1,p-1,
trap(,
print("break here, p="p", y="y);
break
,
b=sqrt(Mod(b,1<<p-1))
);
if(y==p-1,print(p))
);
b=2
)}
|
|
|
|
|
|
#2334 |
|
"Forget I exist"
Jul 2009
Dumbassville
100000110000002 Posts |
after coming across a comment at:
https://oeis.org/A002450 I did some searching about the topic and came across a reference to Sierpinski triangle and rule 90 with that I was able to get to this: Code:
(n)->
a=[[[1,1,1],0],[[1,1,0],1],[[1,0,1],0],[[1,0,0],1],[[0,1,1],1],[[0,1,0],0],[[0,0,1],1],[[0,0,0],0]];
b=matrix(2^(n-1)+2,2^n-1+2);
b[2,(#b+1)/2]=1;
for(x=3,2^(n-1)-1,
for(y=2,#b-3,
for(z=1,#a,
if(a[z][2]==1,
b[x,y+1]=a[z][2]
)
)
)
)
;b
Last fiddled with by science_man_88 on 2011-12-04 at 22:55 |
|
|
|
|
|
#2335 |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
Code:
(19:29)>Sierpinski(4) %352 = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0] [0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0] [0 0 0 0 0 1 0 1 0 1 0 1 0 0 0 0 0] [0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0] [0 0 0 1 0 1 0 0 0 0 0 1 0 1 0 0 0] [0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0] [0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] Code:
(n)->
a=[[[1,1,1],0],[[1,1,0],1],[[1,0,1],0],[[1,0,0],1],[[0,1,1],1],[[0,1,0],0],[[0,0,1],1],[[0,0,0],0]];
b=matrix(2^(n-1)+2,2^n-1+2);
b[2,(#b+1)/2]=1;
for(x=3,2^(n-1)+1,
for(y=1,#b-2,
for(z=1,#a,
if(eval(Vec(Str(b[x-1,y]b[x-1,y+1]b[x-1,y+2])))==a[z][1],
b[x,y+1]=a[z][2]
)
)
)
)
;b
Last fiddled with by science_man_88 on 2011-12-04 at 23:39 |
|
|
|
|
|
#2336 |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
|
|
|
|
|
|
#2337 |
|
"Forget I exist"
Jul 2009
Dumbassville
203008 Posts |
Code:
(09:30)>a=matrix(10,2);print(#a[,1]);print(#a); 10 2 |
|
|
|
|
|
#2338 |
|
"Forget I exist"
Jul 2009
Dumbassville
26·131 Posts |
is there an easy way to create all the distinct partitions of a number n without the number 1 involved ( though I also have a way with 1 involved I think) ? because I'm trying to speed up my aligen function and it's based on partitions.
|
|
|
|
|
|
#2339 | |
|
"Forget I exist"
Jul 2009
Dumbassville
26·131 Posts |
Quote:
n=6; a=n-1=5; a=5=4+1=3+2 the 5 is by itself so square it, then we without duplicating the 1 we took off we get get 5^2,3*2 , gives you 25 and 6 and only those as 5 can't be partitioned in h>3 parts without a 1 being involved. a sigma check on both shows they both work out . Last fiddled with by science_man_88 on 2011-12-30 at 18:04 |
|
|
|
|
|
|
#2340 |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
Code:
homeprime(n)= s=n;until(isprime(s),a=factor(s);b="";for(x=1,#a[,2],until(a[x,2]==0,b=concat(b,Str(a[x,1]));a[x,2]=a[x,2]-1));print(b);s=eval(b)) Last fiddled with by science_man_88 on 2012-02-29 at 17:02 |
|
|
|
|
|
#2341 | |
|
Aug 2006
3·1,993 Posts |
Quote:
Code:
partNo1(n)={
select(v->vecmin(v)>1,partitions(n))
};
partNo1Count(n)=polcoeff((1-'x)/eta('x+'x*O('x^n)), n);
Code:
partNo1(n)={
apply(Vec,select(partitions(n),v->vecmin(v)>1))
};
|
|
|
|
|
|
|
#2342 | |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
Quote:
|
|
|
|
|
|
|
#2343 |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
this gets too complicated really quick:
duplication through permutation is a problem that can up, so was the avoiding using 1's so are the ones with 2 of the same number. so many things to consider, no wonder a lot of people take the other routes. for my purposes 2,3==3,2 1's are unnecessary because I already subtract it from n, the duplicate part means any partition with x,x in it becomes unwanted. |
|
|
|
![]() |
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 |