Find the next square number - MATLAB Cody - MATLAB Central

Problem 42764. Find the next square number

Difficulty:Rate

Given one or more integers n, find the next integer that is a square, for each of them.

Example 1:

n = 1;
out = 4;

Example 2:

n = [5 7 9];
out = [9 9 16];

Solution Stats

50.35% Correct | 49.65% Incorrect
Last Solution submitted on Jun 26, 2025

Problem Comments

Solution Comments

Show comments
Why should you share code?
In a discussion on LInkedin about my recent blog post, Do these...
3
6

Problem Recent Solvers59

Suggested Problems

More from this Author2

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!