Back to course home
0% completed
Vote For New Content
17. Good Number
Problem Statement
Write a Recursive Approach to Check if a Given Digit String Represents a Good Number.
A digit string is good if the digits (0-indexed) at even indices are even and the digits at odd indices are prime ((2, 3, 5, or 7).
Examples:
Sr # | Input | Expected Output | Description |
---|---|---|---|
1 | 02468 | Not Good | Number 6 at index 3 is not a prime number. |
2 | 23478 | Good | All digits at even indices are even, and all digits at odd indices are prime. Therefore, the digit string is considered "good". |
3 | 224365 | Good | All digits at even indices are even, and all digits at odd indices are prime. Therefore, the digit string is considered "good". |
Try it yourself
Try solving this question here:
Python3
Python3
. . . .
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible