我是python的新手,我正在试图弄清楚如何创建一个输入数字的函数,它会给你数字素数。
示例:如果我输入6则返回13.因为13是第6个素数。
除标准库中的模块外,最好没有模块, 谢谢
答案 0 :(得分:0)
这就是你要找的东西:
REM sample to adjust credit value (EDIT 02-12-2018 adds history for QB64)
DEFLNG A-Z
credit = 100 ' starting credit
buy = 10 ' amount to add
sell = 10 ' amount to subtract
DO
COLOR 15
PRINT "Your credit: "; credit
COLOR 14
PRINT " (B)uy for"; buy
PRINT " (S)ell for"; sell
PRINT " (H)istory"
COLOR 15
PRINT "Enter(Q to quit)? ";
LOCATE , , 1
DO
_LIMIT 100 ' remove for Qbasic
b$ = INKEY$
IF LEN(b$) THEN
PRINT
EXIT DO
END IF
LOOP
SELECT CASE LCASE$(b$)
CASE "b"
credit = credit + sell
bought = bought + sell
CASE "s"
credit = credit - buy
sold = sold + buy
CASE "h"
COLOR 14
PRINT "Credits bought:"; bought
PRINT "Credits sold:"; sold
COLOR 15
PRINT "Press a key:";
DO
_LIMIT 100 ' remove for Qbasic
x$ = INKEY$
IF LEN(x$) THEN
PRINT
EXIT DO
END IF
LOOP
CASE "q"
COLOR 7
END
END SELECT
LOOP
END
答案 1 :(得分:0)