Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

66%
+2 −0
Challenges Substring factor

Does a positive integer have a substring as a factor? Input A positive integer. Output One of 2 distinct values to indicate whether the input has a factor that is a strict substring of it...

3 answers  ·  posted 3mo ago by trichoplax‭  ·  last activity 2mo ago by Shaggy‭

#1: Initial revision by user avatar trichoplax‭ · 2024-07-07T01:00:01Z (3 months ago)
Substring factor
Does a positive integer have a [substring](https://en.wikipedia.org/wiki/Substring) as a factor?

## Input
- A positive integer.

## Output
- One of 2 distinct values to indicate whether the input has a factor that is a strict substring of its base 10 (decimal) representation.
- Only strict substrings count - a string does not count as a strict substring of itself.
- A substring must be contiguous, unlike a subsequence.
- The factor does not need to be a prime factor - any divisor will do, including a composite factor or 1.
- Zero is not a factor of any number.

## Examples
### Example with a single digit input
Input: `4`

Output: `false`

A single digit integer has no non-empty strict substrings, so the output for any single digit input will be `false` (or whichever value you choose to consistently represent this).

### Example with a substring factor
Input: `370`

Output: `true`

The input has a substring 37, and 37 is a factor of 370 (that is, 370 can be divided by 37 with no remainder).

### Example with only a subsequence factor
Input: `253`

Output: `false`

The input has a ***subsequence*** 23, and 23 is a factor of 253, but 23 is not a ***substring*** (that is, not a contiguous subsequence), so this does not count. None of the substrings of 253 is a factor of 253.

### Example with a composite factor
Input: `44`

Output: `true`

The input has a substring 4, and 4 is a factor of 44. Factors do not need to be prime.

### Example with 1 as a factor
Input: `31`

Output: `true`

The input has a substring 1, and 1 is a factor of 31.

## Test cases
- Test cases are in the format `input : output`.
- You may use any 2 distinct values in place of `true` and `false`.

```text
4 : false
31 : true
44 : true
253 : false
370 : true
123456 : true
345678 : true
456789 : false
300007 : false
700003 : false
672297 : true
828477 : true
836537 : true
963833 : true
4506337 : true
5480778 : true
6355037 : true
23278699 : true
22222223 : false
```

## Scoring
This is a [code golf challenge]. Your score is the number of bytes in your code. Lowest score for each language wins.

> Explanations are optional, but I'm more likely to upvote answers that have one.


[code golf challenge]: https://codegolf.codidact.com/categories/49/tags/4274 "The code-golf tag"