Skip to content

Conversation

@rakshityadav1868
Copy link

@rakshityadav1868 rakshityadav1868 commented Oct 27, 2025

Description

Added a comprehensive Pascal's Triangle implementation in Java as part of Hacktoberfest 2025.

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Bug fix
  • Documentation update

What was implemented?

  • Created PascalsTriangle.java in the /java directory
  • Implemented the core algorithm to generate Pascal's Triangle
  • Added two printing methods:
    • printTriangleSimple() - Left-aligned simple output
    • printTriangle() - Beautiful centered formatted output
  • Includes comprehensive JavaDoc documentation
  • Input validation for edge cases

Algorithm Details

  • Time Complexity: O(n²) where n is the number of rows
  • Space Complexity: O(n²) for storing the triangle
  • Each number in the triangle is the sum of the two numbers directly above it

Features

✅ Interactive user input via Scanner
✅ Formatted and simple output options
✅ Proper documentation and comments
✅ Input validation (handles edge cases)
✅ Follows repository coding standards

Testing

The implementation includes a main method that can be run directly to test the functionality.

Example Output

For n=5:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1

Related Issue

Resolves the first Hacktoberfest issue for Pascal's Triangle in Java.

Checklist

  • Code follows the style guidelines of this project
  • Comments added for better code readability
  • Documentation updated (if applicable)
  • No new warnings generated
  • Added appropriate JavaDoc comments

Happy Hacktoberfest 2025! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant