83 lines
		
	
	
		
			972 B
		
	
	
	
		
			Markdown
		
	
	
	
	
	
		
		
			
		
	
	
			83 lines
		
	
	
		
			972 B
		
	
	
	
		
			Markdown
		
	
	
	
	
	
| 
								 | 
							
								---
							 | 
						||
| 
								 | 
							
								id: 5900f4091000cf542c50ff1c
							 | 
						||
| 
								 | 
							
								title: 'Problem 157: Solving the diophantine equation'
							 | 
						||
| 
								 | 
							
								challengeType: 5
							 | 
						||
| 
								 | 
							
								forumTopicId: 301788
							 | 
						||
| 
								 | 
							
								dashedName: problem-157-solving-the-diophantine-equation
							 | 
						||
| 
								 | 
							
								---
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								# --description--
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								Consider the diophantine equation 1/a+1/b= p/10n with a, b, p, n positive integers and a ≤ b.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								For n=1 this equation has 20 solutions that are listed below:
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								1/1+1/1=20/10
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								1/1+1/2=15/10
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								1/1+1/5=12/10
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								1/1+1/10=11/10
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								1/2+1/2=10/10
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								1/2+1/5=7/10
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								1/2+1/10=6/10
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								1/3+1/6=5/10
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								1/3+1/15=4/10
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								1/4+1/4=5/10
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								1/4+1/20=3/10
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								1/5+1/5=4/10
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								1/5+1/10=3/10
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								1/6+1/30=2/10
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								1/10+1/10=2/10
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								1/11+1/110=1/10
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								1/12+1/60=1/10
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								1/14+1/35=1/10
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								1/15+1/30=1/10
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								1/20+1/20=1/10
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								How many solutions has this equation for 1 ≤ n ≤ 9?
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								# --hints--
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								`euler157()` should return 53490.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								```js
							 | 
						||
| 
								 | 
							
								assert.strictEqual(euler157(), 53490);
							 | 
						||
| 
								 | 
							
								```
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								# --seed--
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								## --seed-contents--
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								```js
							 | 
						||
| 
								 | 
							
								function euler157() {
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  return true;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								euler157();
							 | 
						||
| 
								 | 
							
								```
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								# --solutions--
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								```js
							 | 
						||
| 
								 | 
							
								// solution required
							 | 
						||
| 
								 | 
							
								```
							 |