Given a positive integer, n, return a, b, c and d, such that

1. n = a*sqrt(b)+c*sqrt(d)

2. a, b, c and d are all positive integers greater than 1

If a solution does not exist, set all four output variables to zero.

Example 1:

n = 41

a = 5

b = 16

c = 7

d = 9

Example 2:

n = 6

a = 0

b = 0

c = 0

d = 0

Solution Stats

105 Solutions

34 Solvers

Last Solution submitted on Dec 02, 2025

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...

Problem Recent Solvers34

Suggested Problems

More from this Author45

Problem Tags

Community Treasure Hunt

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

Start Hunting!