What's wrong with my code?

Hi.
I'm trying to create a program to compute the Riemann zeta function

which is defined as 1+(1/(2^x))+(1/(3^x))+(1/(4^x))+....

for user input of x

and will keep adding as long as the term is less than (1e-7).

but I keep getting 1.79301e-307 for every number I put
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  #pragma hdrstop
#include <iostream>
#include <cmath>
using namespace std;

int main()
{
#define limit 1e-7
cout<<"This program will compute the Riemann zeta function for real values of x>1."<<endl<<endl;
double number, sum, term;
char answer;
cout<<"Enter a value for x. ";
cin>>number;
cout<<"Do you want to continue?";
cin>>answer;
while(term>limit)
{
    sum=0;
    term=0;
    int denominator=1;
    term=(1/(pow(denominator,number)));
    sum=sum+term;
    denominator++;



}
cout<<sum;

}


help please!
The riemann zeta function takes a complex variable so this isn't riemann zeta.

Also,

1
2
3
4
5
6
7
8
9
10
11
12
while(term < limit)
{
    sum=0;
    term=0;
    int denominator=1;
    term=(1/(pow(denominator,number)));
    sum=sum+term;
    denominator++;



}


might help you out.
Last edited on
It might not be because it's an assignment from my cs 101 class

but those are the set of criterias given to me

reversing the sign gives me 1 everytime for some reason :(
Topic archived. No new replies allowed.