文章标题
来源:互联网 发布:淘宝上的天王表是正品 编辑:程序博客网 时间:2024/06/16 14:53
Write a program to check whether a given number is an ugly number.
Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly since it includes another prime factor 7.
Note that 1 is typically treated as an ugly number.
题目给出丑数的定义:质因子中只包含2、3、5的正整数,判定一个数是否是丑数。easy级别,使用三个循环不断除数,直到为1。
var isUgly = function(num) { var factorArr = [2,3,5]; for(var i=0; i<factorArr.length; ++i){ while(num !== 1){ if(num%factorArr[i] === 0){ num /= factorArr[i]; }else{ break; } } } return num===1; };
0 0
- 文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题 文章标题 文章标题 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- Docker+Nginx+tomcat实现一个服务器上多个tomcat的负载均衡
- 剑指offer:表示数值的字符串
- 获取Android手机CPU类型 ARM、ARMV7、NEON
- OSC源码学习随笔.2
- vim配置文件
- 文章标题
- memcache PHP扩展安装配置
- 内建模块-collections
- 199. Binary Tree Right Side View
- tabbar颜色修改
- PHP绑定手机
- 设计模式六大原则
- Thinkphp5 学习笔记之视图
- 运行React-Rative示例工程MyProject报错