Challenge::Find Nivenmorphic Number | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

Challenge::Find Nivenmorphic Number

AĀ Nivenmorphic numberĀ orĀ harshadmorphic numberĀ for a given number base is an integerĀ tĀ such that there exists some harshad numberĀ NĀ whoseĀ digit sumĀ isĀ t, andĀ t, written in that base, terminatesĀ NĀ written in the same base. For example, 18 is a Nivenmorphic number for base 10: 16218 is a harshad number 16218 has 18 as digit sum 18 terminates 16218

4th Oct 2017, 4:07 AM
Kartikey Sahu
Kartikey Sahu - avatar
27 Respostas
+ 6
Hope I understood the definition of a Nivenmorphic number, i.e. the number must be a Niven number AND its final digit(s) must be the sum of its digits. https://code.sololearn.com/cWoxBR13k94p/?ref=app
4th Oct 2017, 5:14 AM
David Ashton
David Ashton - avatar
+ 2
Ok I have to amend the code to check if the sum is also a Niven number. (edit. fixed now)
4th Oct 2017, 5:21 AM
David Ashton
David Ashton - avatar
+ 1
ok.. its for harshad number checking.. one line code detailed code https://code.sololearn.com/cwiDW62WGpVw/?ref=app https://code.sololearn.com/cNu568lDNhWp/?ref=app
4th Oct 2017, 4:55 AM
sayan chandra
sayan chandra - avatar
+ 1
16218 is a Niven number: sum of its digit is 18 and 18 is Niven 16218 terminates with 18 So, 16218 is Nivenmorphic or Harshadmorphic
4th Oct 2017, 5:19 AM
Kartikey Sahu
Kartikey Sahu - avatar
+ 1
This code finds least Harshad number of a base (hopefully Nivenmorphic) integer https://code.sololearn.com/cKKHUiVRw2R4/?ref=app
4th Oct 2017, 11:31 AM
Amr Ibrahim Khudair
Amr Ibrahim Khudair - avatar
0
@Sayan In that way, a whole complex program can be made in one line
4th Oct 2017, 4:30 AM
Kartikey Sahu
Kartikey Sahu - avatar
0
@Kartikey not in python
4th Oct 2017, 4:31 AM
Supersebi3
Supersebi3 - avatar
0
@Supersebi3 You can create in any language
4th Oct 2017, 4:32 AM
Kartikey Sahu
Kartikey Sahu - avatar
0
@sayan your code doesnt seem quite right
4th Oct 2017, 4:32 AM
Supersebi3
Supersebi3 - avatar
0
@Kartikey as python uses forced indentation, it is not possible to write code that comes after if statements, loops or similar in the same line as themselves
4th Oct 2017, 4:33 AM
Supersebi3
Supersebi3 - avatar
0
@Supersebi3 The topic here is not if you can write a while program in one line and my previous answer was not for python
4th Oct 2017, 4:35 AM
Kartikey Sahu
Kartikey Sahu - avatar
0
@Kartikey you answered to me, and i was talking about the indentation... Anyways, i dont quite get the challenge, what exactly is a harshad number?
4th Oct 2017, 4:37 AM
Supersebi3
Supersebi3 - avatar
0
@sayan it looks like it doesnt check if the number terminates the other number, it just checks if the number is in the other number
4th Oct 2017, 4:37 AM
Supersebi3
Supersebi3 - avatar
0
Also, both codes dont check for a nivenmorphic number, but for a harshad number... Both say false if i input 18
4th Oct 2017, 4:40 AM
Supersebi3
Supersebi3 - avatar
0
According to the above definition, that makes 18 not a harshad number, but not not a nivenmorphic number
4th Oct 2017, 4:45 AM
Supersebi3
Supersebi3 - avatar
0
Also, the bases are important apparently
4th Oct 2017, 4:48 AM
Supersebi3
Supersebi3 - avatar
0
True...
4th Oct 2017, 4:50 AM
Supersebi3
Supersebi3 - avatar
0
Maybe theres more to harshad numbers
4th Oct 2017, 4:51 AM
Supersebi3
Supersebi3 - avatar
0
@Kartikey answer
4th Oct 2017, 4:53 AM
Supersebi3
Supersebi3 - avatar
0
Ew whatsapp Use discord
4th Oct 2017, 5:20 PM
Supersebi3
Supersebi3 - avatar