Scriptorium

us fr nl




VBA : Project Euler: Project Euler - Problem #4   nl


Options: Save as PDF | Save attached file | Toggle line numbers

Details:

Type: sub
Added By: Rembo
Short Description:
None
Notes:
The problem description is included with the code.
Added: May 25 2009 at 11:01 AM
Related URLs


Usage:

Run the routine, the answer is printed in the debugging screen.


Code:

Formatted | Unformatted
  1. Sub Euler_0004()
  2. 'A palindromic number reads the same both ways.
  3. 'The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99.
  4. '
  5. 'Find the largest palindrome made from the product of two 3-digit numbers.
  6.  
  7.  
  8. Dim i As Long, i2 As Long
  9. Dim lPalindrome As Long
  10. 'Assume that palindrome is a 6 digit number
  11. '(could be 5 digits but for now ignore that option)
  12. lPalindrome = 0
  13. For i = 999 To 316 Step -1
  14. For i2 = i To 316 Step -1
  15. If bPalindrome(i * i2) Then
  16. If i * i2 > lPalindrome Then
  17. lPalindrome = i * i2
  18. End If
  19. End If
  20. Next i2
  21. Next i
  22. Debug.Print lPalindrome
  23. End Sub



User comments :

Add a new comment   Back to Top
Atom Feed
Contact | About This Application | Scriptorium Website