当前位置:网站首页>L1-028 judging prime number (Lua)
L1-028 judging prime number (Lua)
2022-07-07 19:17:00 【Just be interesting】
subject
The goal of this question is very simple , Is to determine whether a given positive integer is a prime number .
Input format :
Enter a positive integer on the first line N(≤ 10), And then N That's ok , Each line gives a less than 2
31
A positive integer that needs to be judged .
Output format :
For each positive integer to be judged , If it's a prime , Output in one line Yes, Otherwise output No.
sample input :
2
11
111
sample output :
Yes
No
Code
function isPrime(x)
if x == 0 or x == 1 then
return false
end
local i = 2
while i <= x / i do
if x % i == 0 then
return false
end
i = i + 1
end
return true
end
local n = io.read()
for i = 1, n do
local num = tonumber(io.read())
if isPrime(num) then
print("Yes")
else
print("No")
end
end
边栏推荐
- Tapdata 的 2.0 版 ,开源的 Live Data Platform 现已发布
- Longest common prefix (leetcode question 14)
- Short selling, overprinting and stock keeping, Oriental selection actually sold 2.66 million books in Tiktok in one month
- ES6 note 1
- 如何选择合适的自动化测试工具?
- Will low code help enterprises' digital transformation make programmers unemployed?
- AI来搞财富分配比人更公平?来自DeepMind的多人博弈游戏研究
- State mode - Unity (finite state machine)
- PTA 1101 B是A的多少倍
- Mathematical analysis_ Notes_ Chapter 11: Fourier series
猜你喜欢

DeSci:去中心化科学是Web3.0的新趋势?
![Learn open62541 -- [67] add custom enum and display name](/img/98/e5e25af90b3f98c2be11d7d21e5ea6.png)
Learn open62541 -- [67] add custom enum and display name

Do you know all four common cache modes?
![[Blue Bridge Cup training 100 questions] sort scratch from small to large. Blue Bridge Cup scratch competition special prediction programming question centralized training simulation exercise question](/img/08/5f4b4e2700606554516807c01454fd.png)
[Blue Bridge Cup training 100 questions] sort scratch from small to large. Blue Bridge Cup scratch competition special prediction programming question centralized training simulation exercise question

从39个kaggle竞赛中总结出来的图像分割的Tips和Tricks
![[Tawang methodology] Tawang 3W consumption strategy - U & a research method](/img/63/a8c08ac6ec7d654159e5fc8b4423e4.png)
[Tawang methodology] Tawang 3W consumption strategy - U & a research method

Wechat web debugging 8.0.19 replace the X5 kernel with xweb, so the X5 debugging method can no longer be used. Now there is a solution
![[tpm2.0 principle and Application guide] Chapter 16, 17 and 18](/img/7a/b16549590e6445d9199c8000d47d36.png)
[tpm2.0 principle and Application guide] Chapter 16, 17 and 18

Version 2.0 of tapdata, the open source live data platform, has been released

How to share the same storage among multiple kubernetes clusters
随机推荐
Desci: is decentralized science the new trend of Web3.0?
RISCV64
Zhong Xuegao wants to remain innocent in the world
PTA 1102 teaching Super Champion volume
10 schemes to ensure interface data security
[HDU] 5248 sequence transformation (greedy + dichotomy) [recommended collection]
L1-019 who falls first (Lua)
【软件测试】从企业版BOSS直聘,看求职简历,你没被面上是有原因的
Calculation of torque target value (ftorque) in servo torque control mode
Redis publishing and subscription
50亿,福建又诞生一只母基金
IP netns command (memo)
从39个kaggle竞赛中总结出来的图像分割的Tips和Tricks
我感觉被骗了,微信内测 “大小号” 功能,同一手机号可注册两个微信
Creative changes brought about by the yuan universe
I feel cheated. Wechat tests the function of "size number" internally, and two wechat can be registered with the same mobile number
炒股如何开户?请问一下手机开户股票开户安全吗?
Three forms of multimedia technology commonly used in enterprise exhibition hall design
Basic concepts and properties of binary tree
Pasqal首席技术官:模拟量子计算率先为工业带来量子优势