![]() |
they both work until M(1) but after that they climb to 35 and 70 for the next ones.
|
[QUOTE=CRGreathouse;225396]I can't correct the program because I don't know what it's trying to do. But certainly the program isn't doing what you intend if it stores the value it returns but doesn't actually return a value.[/QUOTE]
it's doing the equivalent of the formula I gave above. [URL="http://www.mersenneforum.org/cgi-bin/mimetex.cgi?M(x)=\sum_{n=0}^{x-1}M(n)%20+%20x"]http://www.mersenneforum.org/cgi-bin/mimetex.cgi?M(x)=\sum_{n=0}^{x-1}M(n)%20+%20x[/URL] |
Is x in the sum or out of the sum?
|
[QUOTE=CRGreathouse;225400]Is x in the sum or out of the sum?[/QUOTE]
out I know I wasn't sure how to make it obvious. sum all M(n) less than M(x) then add x to that sum. I realize it should of been first now lol. |
[QUOTE=science_man_88;225401]out I know I wasn't sure how to make it obvious.[/QUOTE]
[TEX]M(x)=x+\sum_{n=0}^{x-1}M(n)[/TEX] would be the usual way. Of course you could also use parentheses (in which case, in LaTeX, you would want to use \left and \right). [code]M(x)=x+sum(n=0,x-1,M(n))[/code] is the literal translation into Pari. Here's a solution with memoization. It stores the values rather than recalculating: [code]M(x)={ if(x < 1, return(0)); if(Mvec == 'Mvec,Mvec=[]); if(#Mvec < x, my(n=#Mvec); Mvec=vector(x,i,if(i<=n,Mvec[i])); for(i=n+1,x, Mvec[i]=i+sum(j=1,i-1,Mvec[j])) ); Mvec[x] };[/code] Here's a more efficient version: [code]M(x)=(1<<x)-1[/code] |
[QUOTE=CRGreathouse;225402][TEX]M(x)=x+\sum_{n=0}^{x-1}M(n)[/TEX] would be the usual way. Of course you could also use parentheses (in which case, in LaTeX, you would want to use \left and \right).
[code]M(x)=x+sum(n=0,x-1,M(n))[/code] is the literal translation into Pari. Here's a solution with memoization. It stores the values rather than recalculating: [code]M(x)={ if(x < 1, return(0)); if(Mvec == 'Mvec,Mvec=[]); if(#Mvec < x, my(n=#Mvec); Mvec=vector(x,i,if(i<=n,Mvec[i])); for(i=n+1,x, Mvec[i]=i+sum(j=1,i-1,Mvec[j])) ); Mvec[x] };[/code] Here's a more efficient version: [code]M(x)=(1<<x)-1[/code][/QUOTE] memorization* and memorize* for the last few posts but thank's and I have proved it works yeah. is there a formula for the number list that contains the super-perfect numbers and perfect numbers as well like mine ? |
[QUOTE=science_man_88;225403]memorization* and memorize*[/QUOTE]
No, memoization and memoize. Different words. [QUOTE=science_man_88;225403]is there a formula for the number list that contains the super-perfect numbers and perfect numbers as well like mine ?[/QUOTE] Not sure what you mean. |
[TEX]M(x)=x+\sum_{n=0}^{x-1}M(n)[/TEX]
is there a similar formula for the sequences that hold super-perfect and perfect numbers respectively? |
[QUOTE=science_man_88;225407][TEX]M(x)=x+\sum_{n=0}^{x-1}M(n)[/TEX]
is there a similar formula for the sequences that hold super-perfect and perfect numbers respectively?[/QUOTE] Yes, but what sequences? Certainly they're in [url=http://oeis.org/classic/A000027]A000027[/url], but did you have a more specific sequence in mind? I don't know of an explicit formula for the (super-)perfect numbers, of course -- though I wouldn't be surprised if one could be formed with sin and floor. :smile: |
[QUOTE=science_man_88;225403]memorization* and memorize* for the last few posts[/QUOTE]
[url]http://en.wikipedia.org/wiki/Memoization[/url] |
[QUOTE=axn;225409][url]http://en.wikipedia.org/wiki/Memoization[/url][/QUOTE]
Thanks, axn. I tend to forget that not everyone is a computer programmer. :blush: |
| All times are UTC. The time now is 22:58. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.