楼主: flin039
1303 1

[问答] invertible function [推广有奖]

  • 0关注
  • 0粉丝

等待验证会员

小学生

28%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
56 点
帖子
5
精华
0
在线时间
0 小时
注册时间
2014-8-15
最后登录
2014-8-17

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
Some digits look (nearly) the same when turned upside-down (0, 1, 8).
Two more come in a pair, each being the other turned upside down (6,
9). The rest (2, 3, 4, 5, 7) don't look like digits when turned upside down.
Some years look the same when turned upside-down. For example, 1691
is unchanged if turned upside down. (Note that turning a year upside
down means turning the digits upside down and reverseing their order.)

Write an R function that can be used to test whether positive integers
are unchanged when turned upside-down. The function should have the
following form.
invertible =
function(n) {
...
}
Given a vector of positive integers, the function should return a vector
of logicals that indicate whether the values look the same when turned
upside-down.
Here is how the function should appear in action.
> invertible(c(1, 96, 99, 123, 1691))
[1] TRUE TRUE FALSE FALSE TRUE

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:function vert CTI ert Fun function

沙发
flin039 发表于 2014-8-15 10:59:51 |只看作者 |坛友微信交流群
Hints: Positive integers, a and b, will be part of a triple whenever the
square root of a^2 + b^2 is an integer. You will need try all combinations
of a and b less than or equal to p 1000 and check whether a < b and that
sqrt(a^2 + b^2) is an integer less than or equal to 1000. Sequence generation,
repetition and subsetting may prove useful.

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-6-24 17:25