Cody

Problem 656. Calculate Euler's phi function

Solution 1962029

Submitted on 6 Oct 2019
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   Fail
y_correct = [ 1, 1, 2, 2, 4, 2, 6, 4, 6, 4, 10, ... 4, 12, 6, 8, 8, 16, 6, 18, 8, 12, ... 10, 22, 8, 20, 12, 18, 12, 28, 8, ... 30, 16, 20, 16, 24, 12, 36, 18, 24, ... 16, 40, 12, 42, 20, 24, 22, 46, 16, ... 42, 20, 32, 24, 52, 18, 40, 24, 36, 28, ... 58, 16, 60, 30, 36, 32, 48, 20, 66, 32, ... 44, 24, 70, 24, 72, 36, 40, 36, 60, 24, ... 78, 32, 54, 40, 82, 24, 64, 42, 56, 40, ... 88, 24, 72, 44, 60, 46, 72, 32, 96, 42, 60]; assert(isequal(eulerphi(1:99),y_correct))

n = Columns 1 through 30 2 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Columns 31 through 60 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 Columns 61 through 90 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 Columns 91 through 99 91 92 93 94 95 96 97 98 99

Operands to the || and && operators must be convertible to logical scalar values. Error in eulerphi/phi (line 6) if k > 1 && rem(k,1)==0 Error in eulerphi (line 25) glan=phi(n) Error in Test1 (line 11) assert(isequal(eulerphi(1:99),y_correct))

2   Fail
assert(isequal(eulerphi(double(intmax('int16'))), 27000)) assert(isequal(eulerphi(double(intmax('uint16'))),32768))

Output argument "glan" (and maybe others) not assigned during call to "eulerphi". Error in Test2 (line 1) assert(isequal(eulerphi(double(intmax('int16'))), 27000))

3   Fail
assert(isequal(eulerphi(double(intmax('int32'))), 2147483646)) assert(isequal(eulerphi(double(intmax('uint32'))),2147483648))

Output argument "glan" (and maybe others) not assigned during call to "eulerphi". Error in Test3 (line 1) assert(isequal(eulerphi(double(intmax('int32'))), 2147483646))