Cody

# Problem 44455. Find the average of a random sequance

Solution 2693768

Submitted on 14 Jul 2020 by Jerry Wright
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
filetext = fileread('MeanWhile.m'); assert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden')

2   Pass
filetext = fileread('MeanWhile.m'); assert(isempty(strfind(filetext, 'sum')),'sum() function is forbidden')

3   Pass
filetext = fileread('MeanWhile.m'); assert(isempty(strfind(filetext, 'mean')),'mean() function is forbidden')

4   Pass
rng(1); av_correct = 5.5; assert(isequal(MeanWhile(),av_correct))

n = 1 s = 4 n = 2 s = 11

5   Pass
rng(2); av_correct = 4; assert(isequal(MeanWhile(),av_correct))

n = 1 s = 4

6   Pass
rng(3); av_correct = 5.25; assert(isequal(MeanWhile(),av_correct))

n = 1 s = 6 n = 2 s = 13 n = 3 s = 16 n = 4 s = 21 n = 5 s = 30 n = 6 s = 39 n = 7 s = 40 n = 8 s = 42

7   Pass
rng(7); av_correct = 0; assert(isequal(MeanWhile(),av_correct))

8   Pass
rng(0); av_correct = 6.571428571428571; assert(isequal(MeanWhile(),av_correct))

n = 1 s = 8 n = 2 s = 17 n = 3 s = 18 n = 4 s = 28 n = 5 s = 34 n = 6 s = 35 n = 7 s = 38 n = 8 s = 44 n = 9 s = 54 n = 10 s = 64 n = 11 s = 65 n = 12 s = 75 n = 13 s = 85 n = 14 s = 90 n = 15 s = 98 n = 16 s = 99 n = 17 s = 103 n = 18 s = 113 n = 19 s = 121 n = 20 s = 131 n = 21 s = 138

### Community Treasure Hunt

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

Start Hunting!