Archive for arithmetics

more fiddlin [to the top]

Posted in Books, Kids with tags , , , on May 13, 2024 by xi'an

Each block in the pyramid above is the product of the two blocks below it, a, b, c, and d are distinct integers that are not perfect squares. What values for a, b, c, and d result in a integer top square value? What’s the smallest possible integer value for the top square?

Multiplying terms to the top of the pyramid return bc√(abcd), hence abcd must be a square x² with none of a,b,c,d being a square. If x=p¹p²p³p⁴ (with all terms distinct but not necessarily prime) and a=p¹p², b=p²p³,c=p³p⁴, and d=p⁴p¹, this works out, unless one of the terms a,b,c,d is a square. For instance, x=24=4x2x1x3 works, with a=8,b=2,c=3 and d=12, resulting in a top value of 6×24=144. Actually, the same applies to x=p¹p²p³ and a=p¹p², b=p¹,c=p³, and d=p²p³, with p²>max(p¹,p³). Then x=2x3x4=24 leads to a pyramid result of 2x3x24=144, which could be the smallest possible value.

merely fiddlin

Posted in Books, Kids, Mountains, pictures, R, Running, Travel with tags , , , , , , , , , on February 25, 2024 by xi'an

For any positive, base-10 integer N, define f(N) as the number of times you have to add up its digits until you get a one-digit number. Find the smallest whole number N such that f(N) = 4. Fiddler on the Proof

Although I first gave in to the R brute force attempt, it failed to return a value for N up to 10⁹, but the solution is obvious as f(N)=p iff F(s(N))=p-1. Since f(19)=2 and f(199)=3, a number N whose sum of digits is 199 is legit, for instance

f(99999999999999999999991)=4

where there are 22 9s. And although it gets a wee bit boring, here is the associated attempt by ChatGPT³

operation precisely impossible

Posted in Books, Kids, R, University life with tags , , , , , , , , , , , , on May 13, 2023 by xi'an

Since the solution to the previous riddle from The Riddler on the maximum of  different terms in the composed operation

a∅b∅c∅d∅e∅f

depending on the bracketing ordering and the meaning of each ∅ among one of the six elementary operations got posted today as 974,860, I got back to my R code to understand why it differed from my figures by two orders of magnitude and realised I was overly trusting the R function unique. As it was returning more “different” entries than it should have, especially when choosing the six starting numbers (a,…,f) as Uniform (0,1). Using integers instead led for instance to 946,558, which was not so far from the target. But still imprecise as to whether or not some entries had been counted several times. I mentioned the issue to Robin, who rose to the challenge and within minutes came up with using the R function almost.unique from the CRAN package bazar, then producing outcomes like 974,513, hence quite close to 974,860 for random initialisations!

operation impossible

Posted in Books, R with tags , , , , , , on April 30, 2023 by xi'an

A riddle from The Riddler on how many different numbers one could at most produce from six initial values and the four basic operations. In other words, how many values could the terms in

a∅(b∅{c∅[d∅(e∅f)]})

and other positioning of the brackets could take? (With each ∅ being one of the four operations and a,…,f the initial values or a permutation of these.) A very crude evaluation leads to twenty million possible values, forgetting that addition and multiplication are commutative, while subtraction and division are anti-commutative. I tried a brute force approach in R, rather than exploring the tree of possible paths, but could not approach this figure by far, the number of different values still increasing for the largest manageable number of replicas I could try. Reducing the initial values at n=3, I could come closer to 123 with 95 different values and, for n=4, not too far from 1972 with 1687 values. Moving to n=6 by hopefully exhausting all (?) entries led to another guess of 50,524,809 values. I am however unsure that the R code is able to spot identical values, given the variability of the above figure…

Carmichael number, more or less

Posted in Books, Kids, Statistics with tags , , , , , , , on May 6, 2022 by xi'an

A quick-and-dirty R resolution of a riddle from The Riddler, namely to find a Carmichael number of the form abcabc:

library(numbers)
for(i in 1:9)
  for(j in 0:9)
    for(k in 0:9){
      x=i*100100+j*1010+k*101
      if(!isPrime(x)){
        p=primeFactors(x)
        if((prod(apply(outer(p,p,F="=="),1,sum)%%2))&
          (!max((x-1)%%(p-1))))break()}}

resulting into the number 101 101, since its prime factors are

> primeFactors(101101)
[1]   7  11  13 101

and 6, 10, 12, and 100 are divisors of 101100:

> primeFactors(101100) 
[1] 2 2 3 5 5 337