Challenge: betrothed numbers | SoloLearn: Learn to code for FREE!

+12

Challenge: betrothed numbers

Betrothed numbers (quasi-amicable numbers) are two positive integers - m,n - satisfying the following relation: sum of dividers of m is n+1 AND sum of dividers of n is m+1 Examples are: (48, 75), (140, 195), (1050, 1925) task: write a code that, given an upper limit, finds all betrothed numbers from 1 to limit and displays the couples write code in any language you prefer :) additional task (the easy part :D): display the couples' count in the given range! good work!

8/22/2017 7:14:19 PM

Luca

47 Answers

New Answer

+4

https://code.sololearn.com/cEBRL2A23iPQ/?ref=app https://code.sololearn.com/cjBYLwf6rych/#cpp

+13

My try. [HTML,CSS,JS] https://code.sololearn.com/WvRowj9um83m/#html You will like it a lot!

+12

please share

+12

Hello please share

+10

thank you

+10

the problem all the answer please?

+9

@Luca Finger trouble, working now.

+4

@Baptiste 48 is also divisible by 3 :) anyway, here there is wikipedia page about betrothed numbers https://en.wikipedia.org/wiki/Betrothed_numbers i think wikipedia is better than me at explaining :D

+4

My attempt in PHP: https://code.sololearn.com/wO40M7D6815K/#php Got a little longer than expected because I had to filter duplicates.

+4

Please Check my code... https://code.sololearn.com/cjcCT83NMnnc/?ref=app

+4

my java try :- https://code.sololearn.com/cXSXqAtknJ95/?ref=app

+4

Betrothed numbers https://code.sololearn.com/ct5au1faVoS5/?ref=app if you input 6200, you get this: [[48, 75], [140, 195], [1050, 1925], [1575, 1648], [2024, 2295], [5775, 6128]] total: 6

+3

@Baptiste sure, you're right, i forgot... added in the OP!

+3

this is my c++ version... Just for :) https://code.sololearn.com/cCYnJQCMaX8j/?ref=app

+3

@Kiew which problem? this is a challenge thread, task was provided in the OP and answers are solution codes/comments on them... no problems :)

+2

Can you give an example of betrothed number please ?

+2

@Baptiste congratulations, i really like your code!

+2

@Antoine here is your code corrected. I saved it as mine only to share the link, all credits (as stated in the code) go to you! https://code.sololearn.com/WxV9u93upSTD/#html

+2

again, thanks everybody for participating the challenge, very appreciated 😊 please give an upvote if you liked it, so (maybe) other users can see it and enjoy it too 😁 hope to see a lot of new answers with new codes!!!

+2

@ysraelcon nice code! may i suggest you to add a control to remove duplicates? :)