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

Comments on Find n Niven Numbers

Post

Find n Niven Numbers

+7
−0

Challenge

A Niven number is a positive integer which is divisible by the sum of its digits.

For example, 81 -> 8+1=9 -> 81%9=0.

Your task is to find the first n Niven numbers, given n.

Tests

Reference implementation(takes input)

first 16 values:

0 => 1
1 => 2
2 => 3
3 => 4
4 => 5
5 => 6
6 => 7
7 => 8
8 => 9
9 => 10
10 => 12
11 => 18
12 => 20
13 => 21
14 => 24
15 => 27
History
Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

2 comment threads

tangent: Niven? (2 comments)
Alternate output formats (2 comments)
Alternate output formats
user‭ wrote over 1 year ago

Could we return an infinite sequence of Niven numbers or return only the nth Niven number?

Razetime‭ wrote over 1 year ago

nah, first n. Having it that flexible is weird imo, so I draw the line at index origin.