Square

Published on January 2017 | Categories: Documents | Downloads: 88 | Comments: 0 | Views: 655
of 1
Download PDF   Embed   Report

Comments

Content

/**
* Write a description of class SquareTriangular here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class SquareTriangular
{
/**
* An example of a method - replace this comment with your own
*
* @param y
a sample parameter for a method
* @return
the sum of x and y
*/
public void printthetriangularnumbers(int n)
{
int count=0;
int sum=0;
for (int j=1;j<=Integer.MAX_VALUE;j++)
{
sum= (int) ((j*(j+1))/2);
if (sum==1)
{
count++;
System.out.println(sum);
if(count==n)
break;
}
else
{
for (int test=1; test<=sum/2; test++)
{if(test*test==sum)
{
count++;
System.out.println(sum);
break;
}
}
}
if(count==n)
{break;}
}
}
}

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close