![]() |
scratch f we can just use v=f to redefine it back to v after.
|
[QUOTE=science_man_88;226201]CRG I got my code to work to find primes and fill a vector of 0's with them I'm thinking of how to make a function VecApp(v,x,f) that takes one vector(v) into another vector(f) with 1 extra element which is appended with value x maybe that will make it easier on me. I think this would need to say something like f[i] = v[i] f[i]+1 = x but I'm without reading them all I have no idea how to get i not to go over the amount of indexes of v.[/QUOTE]
[code]concat([1,2,3],10)[/code] |
I'm an idiot thanks.
|
[QUOTE=CRGreathouse]Just look at my code for how to use the vector!
[/QUOTE] my(v=vectorsmall(sz, i, 1))? What is supposed to be the substitution here? |
[QUOTE=science_man_88;226205]I'm an idiot thanks.[/QUOTE]
You were trying to write a function that already existed. That's pretty common. I wrote my own version of eint1, at the very least -- but probably others, too. |
A 1 in 10[sup]65[/sup] chance:
I entered a(65), which is nextprime(random(10^65)). The result: 2. |
Well, 3 in 10^65 anyway. Wow.
|
[QUOTE=CRGreathouse]Well, 3 in 10^65 anyway. Wow.
[/QUOTE] It was in fact, too good to be true. It turned out PARI was messed for a while. I entered a(7) and got 2, 6 times in a row. I tried a(8) through a(12), and got 2, about 20 times on end. This would normally happen only about 1 in ≈10[sup]163[/sup] times. I'm going with PARI being a bit buggy. Or did I have a supreme stroke of luck and just defy odds of 1 in 10[sup]163[/sup]? Also: The lottery should be changed to guessing 10 random numbers between 1 and 10[sup]15[/sup]. (To ensure that nobody wins, :devil:) |
You may have inadvertently overwritten a. Try ?a to see the current definition.
|
[QUOTE=CRGreathouse]You may have inadvertently overwritten a. Try ?a to see the current definition.
[/QUOTE] Nope. I changed nothing. It was either incredible luck or the computer fucking up. |
[CODE](15:27) gp > v=vector(1,n,0);a=1;for(x=1,10000,if(isprime(x),v[a]=x;concat(v[],0);a=a+1))
[COLOR="Red"]*** unused characters: v=vector(1,n,0);a=1;for(x=1,10000,if(is ^--------------------[/COLOR][/CODE] |
| All times are UTC. The time now is 23:07. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.