Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Name: Lu Liu
- * Date: 11/2/2015
- * Course Number: CSC-111
- * Course Name: Introduction to Java Programming
- * Problem Number:MyprogrammingLab 71077
- * Email:lliu0001@student.stcc.edu
- * Problem Description:pentagonal numbers
- */
- package chapter06;
- import java.util.Scanner;
- public class PentagonalNumbers {
- public static int getPentagonalNumber(int n) {
- return n * ((3 * n) - 1) / 2;
- }
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.println("Enter an integer for the n pengonal numbers you want displays: ");
- int n = input.nextInt();
- for (int i = 1; i <= n; i++) {
- System.out.print(getPentagonalNumber(i) + " ");
- if (i % 10 == 0)
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement