Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
nterms = 10;
term0 = randi(10)
ratio = (-1)^randi(2)*randi(10)
correctsequence = term0*ratio.^(0:nterms-1);
for position = 1:nterms
errorsequence = correctsequence;
errorsequence(position) = errorsequence(position) + (-1)^randi(2)*randi(50);
[errorposition, truesequence] = find_error(errorsequence);
assert(errorposition == position && isequal(truesequence, correctsequence), 'failed test 1 at position %d', position);
end
term0 =
10
ratio =
7
er =
10 70 490 3430 24010 168070 1176490 8235430 57648010 403536070
er =
10 70 490 3430 24010 168070 1176490 8235430 57648010 403536070
er =
10 70 490 3430 24010 168070 1176490 8235430 57648010 403536070
er =
10 70 490 3430 24010 168070 1176490 8235430 57648010 403536070
er =
10 70 490 3430 24010 168070 1176490 8235430 57648010 403536070
er =
10 70 490 3430 24010 168070 1176490 8235430 57648010 403536070
er =
10 70 490 3430 24010 168070 1176490 8235430 57648010 403536070
er =
10 70 490 3430 24010 168070 1176490 8235430 57648010 403536070
er =
10 70 490 3430 24010 168070 1176490 8235430 57648010 403536070
er =
10 70 490 3430 24010 168070 1176490 8235430 57648010 403536070
|
2 | Pass |
nterms = 15;
term0 = randi(10)
ratio = (-1)^randi(2)*randi(10)
correctsequence = term0*ratio.^(0:nterms-1);
for position = 1:nterms
errorsequence = correctsequence;
errorsequence(position) = errorsequence(position) + (-1)^randi(2)*randi(50);
[errorposition, truesequence] = find_error(errorsequence);
assert(errorposition == position && isequal(truesequence, correctsequence), 'failed test 2 at position %d', position);
end
term0 =
10
ratio =
5
er =
1.0e+10 *
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0004 0.0020 0.0098 0.0488 0.2441 1.2207 6.1035
er =
1.0e+10 *
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0004 0.0020 0.0098 0.0488 0.2441 1.2207 6.1035
er =
1.0e+10 *
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0004 0.0020 0.0098 0.0488 0.2441 1.2207 6.1035
er =
1.0e+10 *
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0004 0.0020 0.0098 0.0488 0.2441 1.2207 6.1035
er =
1.0e+10 *
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0004 0.0020 0.0098 0.0488 0.2441 1.2207 6.1035
er =
1.0e+10 *
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0004 0.0020 0.0098 0.0488 0.2441 1.2207 6.1035
er =
1.0e+10 *
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0004 0.0020 0.0098 0.0488 0.2441 1.2207 6.1035
er =
1.0e+10 *
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0004 0.0020 0.0098 0.0488 0.2441 1.2207 6.1035
er =
1.0e+10 *
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0004 0.0020 0.0098 0.0488 0.2441 1.2207 6.1035
er =
1.0e+10 *
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0004 0.0020 0.0098 0.0488 0.2441 1.2207 6.1035
er =
1.0e+10 *
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0004 0.0020 0.0098 0.0488 0.2441 1.2207 6.1035
er =
1.0e+10 *
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0004 0.0020 0.0098 0.0488 0.2441 1.2207 6.1035
er =
1.0e+10 *
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0004 0.0020 0.0098 0.0488 0.2441 1.2207 6.1035
er =
1.0e+10 *
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0004 0.0020 0.0098 0.0488 0.2441 1.2207 6.1035
er =
1.0e+10 *
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0004 0.0020 0.0098 0.0488 0.2441 1.2207 6.1035
|
1726 Solvers
519 Solvers
Test if a Number is a Palindrome without using any String Operations
181 Solvers
169 Solvers
Integer Sequence - II : New Fibonacci
252 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!