![]() |
|
|
#760 |
|
"Forget I exist"
Jul 2009
Dumbassville
20C016 Posts |
if your printing inside a if to get these switch it to if(,,) form and switch which of the last 2 it's in.
|
|
|
|
|
|
#761 | |
|
May 2010
Prime hunting commission.
24×3×5×7 Posts |
Quote:
Last fiddled with by 3.14159 on 2010-08-23 at 14:59 |
|
|
|
|
|
|
#762 |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
Code:
if(x%6==1 || x%6==5 ,print(x)) Code:
if(x%6==1 || x%6==5 ,print(x),) if i want the opposite i just change the position to the other and i get. Code:
if(x%6==1 || x%6==5 ,,print(x)) Code:
if(x%6!=1 && x%6!=5 ,print(x)) |
|
|
|
|
|
#763 |
|
"Forget I exist"
Jul 2009
Dumbassville
838410 Posts |
Code:
(12:10) gp > for(x=1,20,if(x%6==1 || x%6==5,print(x))) 1 5 7 11 13 17 19 (12:10) gp > for(x=1,20,if(x%6==1 || x%6==5,,print(x))) 2 3 4 6 8 9 10 12 14 15 16 18 20 (12:10) gp > |
|
|
|
|
|
#764 |
|
Aug 2006
10111010110112 Posts |
Yes, but you shouldn't be printing at all. Instead of writing print(x) you should be writing something like v[x] = 0.
|
|
|
|
|
|
#765 |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
I was just giving example code for him to look over.
|
|
|
|
|
|
#766 | |
|
May 2010
Prime hunting commission.
24·3·5·7 Posts |
Quote:
|
|
|
|
|
|
|
#767 |
|
"Forget I exist"
Jul 2009
Dumbassville
203008 Posts |
not if you make a vector and try to edit it on the fly like I sent in a pm to CRG the hard part for me was not filling it with 0's as he wanted me to.
can't remeber what i did to make it act dynamic but I can try to figure it out. Last fiddled with by science_man_88 on 2010-08-23 at 15:26 |
|
|
|
|
|
#768 |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
Code:
v=vector(1,n,0);for(x=1,10,if(isprime(x),v=concat(v,x)));for(i=1,(#v)-1,v[i]=v[i+1]) doh vecextract can work lol I just extract the last one. didn't work. Last fiddled with by science_man_88 on 2010-08-23 at 15:39 |
|
|
|
|
|
#769 |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
made a code that works by replacing the 0 with 2 and starting at 3 and searching then I didn't need the index shift code.
Last fiddled with by science_man_88 on 2010-08-23 at 15:52 |
|
|
|
|
|
#770 |
|
Aug 2006
597910 Posts |
Doesn't that message tell you what to do?
It says, "v isn't a vector, so I can't treat it like a vector". So... drumroll... you need to make a vector v. This is done with the vector command, unsurprisingly: Code:
v=vector(1000) |
|
|
|
![]() |
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 |