Cody

Problem 44788. Find the right number make the equation

Solution 2980714

Submitted on 22 Sep 2020 by Rafael S.T. Vieira
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
fid = fopen('exact_sqrt.p','wb'); fwrite(fid,sscanf('7630312E30307630302E3030000CD01C075E1FB1000000F50000013F000002084A6250378D76402208455D72089B6355C54CE41DAC5E5D8129D83CBBAA1298A3BE0AFCD19ECC54791798C1E7C908661803C1E84CE1A34089045C234BBA103F7F21225744CD37C61C65D6FE689DCBA50D9A70776FEA59EC224810665D53FDAEF2D71449ECE6BABA1B97F1070DBBBB7ACDF5C88F8746488D240C547290A48071B3B492C3ADEE8AEDA6D726D76AC58C7BAAB8B6EEB627053173E88789D827D53FFA23337CE20BDD3DE6DFA095DED77BB8CB39C2A19D01D19598138320A2005B359B41990D2056B0F58DAA63A7CD89DB3E986F894F2F4798965E19ACE7B495E38FE1F1B836A3052787B54FD1662FD63F8AA1136D1D92BA3992E68837ACE9C7D1FD906D9C50B45409E0B8605994EF31A6D8AFFE676ACB24F9485643451A5565A9A515D7772D35B07198F84F45095F77985BE91C7A7CB54245F80C26DC1DC1FFB8FC','%2x')); fclose(fid);

2   Pass
for n = 1 : 3 [a, b] = find_right_number_for_F(n); assert(ischar(a)); assert(ischar(b)); a = java.math.BigInteger(a); b = java.math.BigInteger(b); c = a.add(b.multiply(java.math.BigInteger(int2str(n)))); [~, r] = exact_sqrt(char(c)); assert(isequal(r,'0')); d = a.pow(2).add(b.pow(2)); [e,r1] = exact_sqrt(char(d)); assert(isequal(r1,'0')); [~,r2] = exact_sqrt(char(e)); assert(isequal(r2,'0')); end

Suggested Problems

More from this Author17

Community Treasure Hunt

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

Start Hunting!