All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > General
Year from Ratio (Posted on 2016-08-22) Difficulty: 3 of 5
S denotes the sum of the digits and P denotes the product of the nonzero digits.
It is observed that for the year 2016, S = 9 and P = 12, so that:
S:P = 3:4

Determine all years from 2000 to 3000 such that:
S:P = 3:4

No Solution Yet Submitted by K Sengupta    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution re: No Subject Comment 3 of 3 |
(In reply to No Subject by Ady TZIDON)

2016 and 2061 are missing from your list; of course the former was present in the puzzle itself, but not the latter.


year sod pod(nz)
2004   6   8
2016   9  12
2022   6   8
2040   6   8
2061   9  12
2106   9  12
2118  12  16
2160   9  12
2181  12  16
2202   6   8
2220   6   8
2400   6   8
2601   9  12
2610   9  12
2811  12  16

from

DefDbl A-Z
Dim crlf$


Private Sub Form_Load()
 Form1.Visible = True
 
 
 Text1.Text = ""
 crlf = Chr$(13) + Chr$(10)
 
 For y = 2000 To 2999
   DoEvents
   If 4 * sod(y) = 3 * podnz(y) Then
     Text1.Text = Text1.Text & y & mform(sod(y), "###0") & mform(podnz(y), "###0") & crlf
   End If
 Next
 
 Text1.Text = Text1.Text & crlf & " done"
  
End Sub

Function mform$(x, t$)
  a$ = Format$(x, t$)
  If Len(a$) < Len(t$) Then a$ = Space$(Len(t$) - Len(a$)) & a$
  mform$ = a$
End Function

Function sod(n)
  s$ = LTrim(Str(n))
  tot = 0
  For i = 1 To Len(s$)
   tot = tot + Val(Mid(s$, i, 1))
  Next
  sod = tot
End Function

Function podnz(n)
  s$ = LTrim(Str(n))
  tot = 1
  For i = 1 To Len(s$)
   If Mid(s, i, 1) <> "0" Then tot = tot * Val(Mid(s$, i, 1))
  Next
  podnz = tot
End Function


  Posted by Charlie on 2016-08-23 19:52:39
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (4)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2017 by Animus Pactum Consulting. All rights reserved. Privacy Information