21/03/14 20:48:56.97 tbIfX8gb.net
>>829
√(n^2+72)の72を他の数値に変えて答を出すプログラムを作ってみた。
calc <- function(n72){
library(numbers)
is.wholenumber = function(x, tol = .Machine$double.eps^0.5) abs(x - round(x)) < tol
d=divisors(n72)
e=cbind(d,n72/d)
re=apply(e,1,function(x) (x[1]-x[2])/2)
re[is.wholenumber(re)]
}
> calc(72)
[1] -17 -7 -3 3 7 17
> calc(2021)
[1] -1010 -2 2 1010
> calc(123)
[1] -61 -19 19 61
# 解のない場合
> calc(1234)
numeric(0)