lundi 5 février 2018

Creating a program to output 4 of the triangular square numbers

I'm creating a program to just output the first four triangular square numbers (1,36,1225,41616), but its only outputting "Square Triangular Number 1 is: 0". What am I doing wrong? Still new to C++.

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
    for(int i=1;i<=4;i++);
    {
        int x=1;
        int test=0;
        test+=(1/32)*((pow((17+12*sqrt(2)),x))+(pow((17-12*sqrt(2)),x)-2));
        cout<<"Square Triangular Number 1 is: "<<test<<endl;
        x+=1;
    }

    return 0;
}

Aucun commentaire:

Enregistrer un commentaire