mersenneforum.org  

Go Back   mersenneforum.org > Math Stuff > Computer Science & Computational Number Theory > PARI/GP

Reply
 
Thread Tools
Old 2010-08-20, 19:17   #738
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

135338 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
can setsearch be used on strings
setsearch works on sets and also on ordered vectors, but not on arbitrary vectors or strings.

I suggest you start by writing a "stringsearch(string_to_search, string_to_find)" function.
CRGreathouse is offline   Reply With Quote
Old 2010-08-20, 19:40   #739
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

32208 Posts
Default

Quote:
Originally Posted by CRGreathouse
setsearch works on sets and also on ordered vectors, but not on arbitrary vectors or strings.

I suggest you start by writing a "stringsearch(string_to_search, string_to_find)" function
Reduced the amount of arguments to three. I think it will be easier to make the appropriate substitutions and modifications now.
3.14159 is offline   Reply With Quote
Old 2010-08-20, 19:47   #740
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
setsearch works on sets and also on ordered vectors, but not on arbitrary vectors or strings.

I suggest you start by writing a "stringsearch(string_to_search, string_to_find)" function.
yeah I found lex so
Code:
y=Vec(input());if(lex(y,"yes"),print("no"))
now all we need is to check indexes against a vector of strings I think.
science_man_88 is offline   Reply With Quote
Old 2010-08-20, 23:47   #741
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

203008 Posts
Default

oh one thing I forgot is maybe using vecextract to another vector may help comparison. as if the input is longer than the text to check against then it can never be equal so maybe extraction of the first #try[x] characters to a new vector and if we want to reuse the input we can concat() /// to the end or something then place that other vector concat() on the end then take the next until we hit out end symbol. then check the next string to check for.
science_man_88 is offline   Reply With Quote
Old 2010-08-21, 12:45   #742
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

20C016 Posts
Default

Code:
y=Vec(input());t=vecextract(y,"1..10");return(t)
my best attempt with vecextract i can't figure out the variables use I get a incorrect range error.
science_man_88 is offline   Reply With Quote
Old 2010-08-21, 20:35   #743
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

well i got it working for 1 but I get a vector of numbers back not a string. got it working for a character but I needed quotes around the whole thing which is better than quotes around every phrase I guess. now I think i figured it out lol. well i can search for it now to replace it I'll put the find code together soon.

Last fiddled with by science_man_88 on 2010-08-21 at 20:41
science_man_88 is offline   Reply With Quote
Old 2010-08-21, 20:55   #744
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

100000110000002 Posts
Default

Code:
(17:49) gp > y=Vec(input());for(i=1,#try,c=vecextract(y,[1,2,3,4,5,6]);if(lex(c,try[i]),print(c)))
"string""suck""primes"
["s", "t", "r", "i", "n", "g"]
["s", "t", "r", "i", "n", "g"]
best I have so far.
science_man_88 is offline   Reply With Quote
Old 2010-08-22, 23:41   #745
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24·3·5·7 Posts
Default

Okay: Returned from a camping trip.

Has there been any progress on the project I was working on?
3.14159 is offline   Reply With Quote
Old 2010-08-23, 12:06   #746
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24×3×5×7 Posts
Default

A quick proposition:

Primes of the form k * b!n + 1, where k < b!n, and where n > 1. (If n were allowed to be 1, every odd prime of the form 6n + 1 would be a prime of the form k * b!n + 1.)

Or: Simply that k * b!n must be divisible by a square number greater than 1.

I'll see if all numbers that fit those conditions are present in the OEIS. (Smallest one is 5.) Oh, wait.. Those would be all the 4n + 1 numbers. Nevermind.

Last fiddled with by 3.14159 on 2010-08-23 at 12:18
3.14159 is offline   Reply With Quote
Old 2010-08-23, 13:23   #747
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

203008 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
Or: Simply that k * b!n must be divisible by a square number greater than 1.
this fits:

4x+1
9x+1
16x+1 (variant of 4x+1)
25x+1


and hence only primes^2 need to be used.
science_man_88 is offline   Reply With Quote
Old 2010-08-23, 13:42   #748
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24×3×5×7 Posts
Default

Quote:
Originally Posted by science_man_88
this fits:

4x+1
9x+1
16x+1 (variant of 4x+1)
25x+1


and hence only primes^2 need to be used.
k * b!n + 1, where k < b!n.

Which means, every 4n + 1 number could not be expressed as k * b!n + 1, where k ≤ b!n

Ex: 7 * 2!2 + 1 is not a valid number of this form, although it is prime (7 > 4) (7 * 2!2 + 1 = 29 = p.)

Now, I need to hunt numbers of that form and fit them all into a sequence and see if it is already in the OEIS.

Note: The n > 1 restriction was found to be unnecessary.

The sequence begins: 3, 5, 7, 9, 13, 17, 19, 25, 33, 37, 41, 49, 65..(This is where only b! is allowed, as opposed to any integer b.)

3: 1 * 2!^1 + 1
5: 1 * 2!^2 + 1 (Fermat number)
7: 1 * 3!^1 + 1
9: 1 * 2!^3 + 1
13: 2 * 3!^1 + 1
17: 1 * 2!^4 + 1 (Fermat number)
19: 3 * 3!^1 + 1
25: 4!^1 + 1
33: 2 * 2!^4 + 1
37: 3!^2 + 1
41: 5 * 2!^3 + 1
49: 2 * 4!^1 + 1
65: 4 * 2!^4 + 1

Last fiddled with by 3.14159 on 2010-08-23 at 14:00 Reason: Skipped 9 in sequence.
3.14159 is offline   Reply With Quote
Reply



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

All times are UTC. The time now is 23:06.


Fri Aug 6 23:06:20 UTC 2021 up 14 days, 17:35, 1 user, load averages: 4.38, 3.93, 3.93

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.