Home c++ Solve an example on C++

Solve an example on C++

Author

Date

Category

It does not turn out to describe this example on C++, tried through arrays, but a full porridge was obtained.

p = (1-1 / 22) * (1-1 / 32) … (1-1 / N2)
N = (N & GT; 2).


Answer 1

#include & lt; cmath & gt;
Double F (unsigned int n)
{
   IF (N & LT; = 2)
     Return -1.0;
   Double Value = 1;
   For (unsigned int i = 2; i & lt; = n; i ++)
   {
     Value * = (1 - 1 / POW (I, 2));
   }
   RETURN VALUE;
}
INT MAIN ()
{
   For (unsigned int i = 2; i & lt; 100; i ++)
     PrintF ("% 1.9f \ n", f (i));
}

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions