mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   PARI/GP (https://www.mersenneforum.org/forumdisplay.php?f=155)
-   -   PARI's commands (https://www.mersenneforum.org/showthread.php?t=13636)

CRGreathouse 2010-08-20 19:17

[QUOTE=science_man_88;226401]can setsearch be used on strings[/QUOTE]

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.

3.14159 2010-08-20 19:40

[QUOTE=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[/QUOTE]

Reduced the amount of arguments to three. I think it will be easier to make the appropriate substitutions and modifications now.

science_man_88 2010-08-20 19:47

[QUOTE=CRGreathouse;226404]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.[/QUOTE]

yeah I found lex so [CODE]y=Vec(input());if(lex(y,"yes"),print("no"))[/CODE]

now all we need is to check indexes against a vector of strings I think.

science_man_88 2010-08-20 23:47

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 2010-08-21 12:45

[CODE]y=Vec(input());t=vecextract(y,"1..10");return(t)[/CODE]

my best attempt with vecextract i can't figure out the variables use I get a incorrect range error.

science_man_88 2010-08-21 20:35

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.

science_man_88 2010-08-21 20:55

[CODE][COLOR="Yellow"](17:49) gp > [COLOR="White"]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"][/COLOR][/COLOR][/CODE]
best I have so far.

3.14159 2010-08-22 23:41

Okay: Returned from a camping trip.

Has there been any progress on the project I was working on?

3.14159 2010-08-23 12:06

A quick proposition:

Primes of the form k * b![sup]n[/sup] + 1, where k < b![sup]n[/sup], 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![sup]n[/sup] + 1.)

Or: Simply that k * b![sup]n[/sup] 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.

science_man_88 2010-08-23 13:23

[QUOTE=3.14159;226641]
Or: Simply that k * b![sup]n[/sup] must be divisible by a square number greater than 1.[/QUOTE]

this fits:

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


and hence only primes^2 need to be used.

3.14159 2010-08-23 13:42

[QUOTE=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.[/QUOTE]

[I][B]k * b![sup]n[/sup] + 1, where k < b![sup]n[/sup].[/B][/I]

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

Ex: 7 * 2![sup]2[/sup] + 1 is not a valid number of this form, although it is prime (7 > 4) (7 * 2![sup]2[/sup] + 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


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

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