Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: calculating euler products [newbie]
Replies: 2   Last Post: Jan 5, 2012 3:21 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Jean Dupont

Posts: 7
Registered: 1/5/12
calculating euler products [newbie]
Posted: Jan 5, 2012 12:35 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I've written the function below to calculate euler-products, I was
wondering how it can be improved i.e. written more in "matlab-style"
perhaps reducing execution time for large numbers

regards,
Jean

function eulerprod(n)
%calculate PI(1/(1-p^-1)) for all primes smaller than n
prime=primes(n);
nop=length(prime)
factor=1
for i=1:nop
factor=factor/(1-prime(i)^(-1));
y(i)=factor;
end
plot([1:nop],y)



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.