Author: Luca Zanini
-
Number spiral diagonals
From the Project Euler Problem 28: Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows: 21 22 23 24 25 20 7 8 9 10 19 6 1 2 11 18 5 4 3 12 17 16 15 14 13 It…
-
Quadratic primes
From the Project Euler Problem 27: Euler discovered the remarkable quadratic formula: n² + n + 41 It turns out that the formula will produce 40 primes for the consecutive values n = 0 to 39. However, when n = 40, 40² + 40 + 41 = 40(40 + 1) + 41 is divisible by…
-
Getting the Context inside a Fragment
It is very easy to get the Context inside an Activity: with the getApplicationContext() method using only “this” because the Activity class extends the Context class But you can’t use any of these two methods inside a Fragment and you have to replace them respectively with: getActivity().getApplicationContext() getActivity() I often do this replacement when I…
-
How to set a default method to running code on the creation or destruction of a bean
In the post Executing code on the creation or destruction of a bean in Spring I explain three ways to execute code on the creation or destruction of a Bean in Spring. With two of these ways you can set the execution of a specific custom method: with the annotations @PostConstruct and @PreDestroy configuring the…
-
Reciprocal cycles
From the Project Euler Problem 26: A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to 10 are given: 1/2 = 0.5 1/3 = 0.(3) 1/4 = 0.25 1/5 = 0.2 1/6 = 0.1(6) 1/7 = 0.(142857) 1/8 = 0.125 1/9 = 0.(1) 1/10 = 0.1…
-
1000-digit Fibonacci number
From the Project Euler Problem 25: The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 F6 = 8 F7 =…
-
# vs $ in the computed expressions in the xpages
In the xml code of the xpages the computed expressions begin with the character “#” or with the character “$”, ie they are one of the following types: value=”#{[language]:[expression]}” value=”${[language]:[expression]}” where [language] is the name of the language, for example javascript and [expression] is the expression to compute. The question is “what is the difference…
-
How to access to a control connected to a lotus field using javascript
In this post I test how to access via javascript to the following controls connected to a lotus field: Edit Box: a control for entering a single line of data Hidden Input: a control for hiding data to the user A Hidden Input control is not such as an Edit Box control with “Visible” unchecked…
-
Lexicographic permutations
From the Project Euler Problem 24: A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order. The lexicographic permutations of 0, 1 and 2 are: 012 021…