Grokking the Art of Recursion for Coding Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
17. Good Number
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

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 #InputExpected OutputDescription
102468Not GoodNumber 6 at index 3 is not a prime number.
223478GoodAll digits at even indices are even, and all digits at odd indices are prime. Therefore, the digit string is considered "good".
3224365GoodAll 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