#1922

Count Good Numbers

specialist · 780 · lc medium +31 · verified · 57.4% accepted · 2,412 likes · top 53%

Description

A digit string is good if every even-indexed digit is even and every odd-indexed digit is prime (2, 3, 5, or 7).

Given an integer n, return the count of good digit strings of length n modulo 109 + 7.

Example 1:

Input: n = 1
Output: 5
Explanation: The good numbers of length 1 are "0", "2", "4", "6", "8".

Example 2:

Input: n = 4
Output: 400

Example 3:

Input: n = 50
Output: 564908303

Code

1
2
3