![]() |
|
|
#1893 |
|
May 2010
Prime hunting commission.
24×3×5×7 Posts |
How about we simply apply the iterative definition?
Start with a. a + 1 Let a + b = a + 1 + 1 + 1 + 1 + 1 + 1 + 1.... Let a * b = a + a + a + a + a + a + a + a + a + .... Let a^b = a * a * a * a * a * a.. Etc. Last fiddled with by 3.14159 on 2010-12-02 at 00:28 |
|
|
|
|
|
#1894 | |
|
May 2010
Prime hunting commission.
32208 Posts |
Quote:
|
|
|
|
|
|
|
#1895 |
|
"Forget I exist"
Jul 2009
Dumbassville
26·131 Posts |
http://rosettacode.org/wiki/Palindrome_detection
I think i have a way to do this: 1) create a Vec with the string 2) call a loop to check if v[i] and v[#v-i] or something like that if 1 based array to check if it's the same if so for all the ones around the center it proves it's a palindrome if I remember my definitions lol. Last fiddled with by science_man_88 on 2010-12-02 at 00:28 |
|
|
|
|
|
#1896 |
|
May 2010
Prime hunting commission.
24·3·5·7 Posts |
All that would have to be done to follow that nice iterative process would be to define a + 1.
Or would that also be disallowed? There would also be the problem of the opposites of those; a - 1, a - b, a/b, a^(1/b), etc. Last fiddled with by 3.14159 on 2010-12-02 at 00:30 |
|
|
|
|
|
#1897 |
|
Aug 2006
597910 Posts |
It is for some -- listed at
http://rosettacode.org/wiki/Category:PARI/GP/Omit though you're welcome to try even those if you have a mind to. I put most of those there because Pari would be bad at them, but in some cases it's literally incapable of doing them without system() or extern() or the like. But for many of the tasks Pari is well-suited. |
|
|
|
|
|
#1898 |
|
Aug 2006
3·1,993 Posts |
|
|
|
|
|
|
#1899 |
|
Aug 2006
10111010110112 Posts |
It's not at all clear how you'd code this. (Yes, I know of a way to code it, but I'm not sure that it's related to what you're saying.) And wouldn't that method be slow? If 2^1000 expands out into the (2^1000 - 1)-times-iterated successor of 1, it will take at least 2^1000 - 1 steps to compute...
|
|
|
|
|
|
#1900 | |
|
May 2010
Prime hunting commission.
110100100002 Posts |
Quote:
a + 1, a + b, a * b, a^b should be independent of each other. Albeit, I think I would have to defy the rule and use the built-in calculator. Last fiddled with by 3.14159 on 2010-12-02 at 00:40 |
|
|
|
|
|
|
#1901 |
|
Aug 2006
3·1,993 Posts |
But if the exponentiation function calls the multiplication function, and the multiplication function calls the addition function, and the addition function calls the successor function, then you will have a total of 2^1000 - 1 calls to the successor function unless you memoize the results (etc.).
|
|
|
|
|
|
#1902 |
|
"Forget I exist"
Jul 2009
Dumbassville
203008 Posts |
|
|
|
|
|
|
#1903 |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
Code:
palindrome(string) ={
my(string=eval(Vec(Str(string))));
for(x=1,ceil(#string/2),
if(string[x]!=string[#string-(x-1)],
break(),
print(string)
)
);
}
|
|
|
|
![]() |
| Thread Tools | |
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 |