Print star pattern count
Java
Easy
5 views
Problem Description
Task: return total stars printed in a triangle of height n (1+2+...+n).
Output Format
Return value
Constraints
Use formula or loop.
Official Solution
static long totalStars(int n){return 1L*n*(n+1)/2;}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!