Cody

# Problem 45994. Investigate the frequency of last digits of prime numbers

Solution 3764623

Submitted on 21 Nov 2020 by David Hill
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
n = 100; f_correct = [0 0.6000 0.4000 0; 0 0 0.3333 0.6667; 0.6667 0.1667 0 0.1667; 0.4000 0.4000 0.2000 0]; assert(isequal(round(primeLastDigit(n),4),f_correct))

2   Pass
n = 149; f_correct = [0 0.5714 0.4286 0; 0 0 0.5000 0.5000; 0.5556 0.1111 0 0.3333; 0.3750 0.3750 0.1250 0.1250]; assert(isequal(round(primeLastDigit(n),4),f_correct))

3   Pass
n = 1e4; f_correct = [0.1340 0.3399 0.4020 0.1242; 0.1715 0.1036 0.3236 0.4013; 0.2922 0.2890 0.0974 0.3214; 0.4026 0.2772 0.1815 0.1386]; assert(isequal(round(primeLastDigit(n),4),f_correct))

4   Pass
n = 1e6; f_correct = [0.1638 0.3211 0.3339 0.1812; 0.2231 0.1430 0.2959 0.3380; 0.2583 0.2774 0.1464 0.3178; 0.3546 0.2609 0.2234 0.1610]; assert(isequal(round(primeLastDigit(n),4),f_correct))

5   Pass
n = 1e8; f_correct = [0.1770 0.3039 0.3103 0.2087; 0.2364 0.1667 0.2869 0.3101; 0.2558 0.2732 0.1668 0.3042; 0.3308 0.2562 0.2362 0.1768]; assert(isequal(round(primeLastDigit(n),4),f_correct))

### Community Treasure Hunt

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

Start Hunting!