61阅读

100以内的质数-100以内质数口诀

发布时间:2017-11-09 所属栏目:100以内的质数表

一 : 100以内质数口诀

100以内质数口诀

二,三,五,七,一十一;
一三,一九,一十七;
二三,二九,三十七;
三一,四一,四十七;
四三,五三,五十九;
六一,七一,六十七;
七三,八三,八十九;
再加七九,九十七;
25个质数不能少;
百以内质数心中记。

口诀2

二三五七和十一,
十三后面是十七,
还有十九别忘记,
二三九, 三一七,
四一,四三,四十七,
五三九, 六一七,
七一,七三,七十九,
八三,八九,九十七.

这些质数要牢记。

二 : 巧记100以内的质数

[100以内的质数]巧记100以内的质数——简介
质数又称“素数”,是指只有1和它本身两个正因数的自然数。在公务员考试笔试题中行政职业能力测验部分为常考内容,所以抓住其特点,巧妙的运用,对于在考试中做到不失分是十分重要的。
[100以内的质数]巧记100以内的质数——100以内的质数:
2、3、5、7、11、13、17、19、23、29、31、37、41、43、47、53、59、61、67、71、73、79、83、89、97,共计25个。
[100以内的质数]巧记100以内的质数——规律一:看区间质数的个数
以10个数为一个区间看质数的个数,呈4,4,2,2,3,2,2,3,2,1规律。
[100以内的质数]巧记100以内的质数——规律二:看每个质数的个位数
100以内的质数个位数有以下几种:1,2,3,5,7,9,共6种情况。
[100以内的质数]巧记100以内的质数——规律三:看区间有2或3个质数的个位数
区间有2个质数的个位数规律为:3,9,或1,7
区间有3个质数的个位数规律为:1,3,7或1,3,9
[100以内的质数]巧记100以内的质数——注意事项
反复观察其本身有很多的规律可循,一种或二种方法记忆,最终记住为目的。

三 : 如何编程求解 100 以内的质数?


网友Belleve[100以内的质数]如何编程求解 100 以内的质数?给出的答复:
Wireworld 机械图,可以逐个在七段数码管里显示素数。这玩意 Golly 里有对应的 rle,可以直接打开运行(记得调高速度到 10000x)。来源图中已包含。
对应的「汇编语言」是:对应的「汇编语言」是:

Reg Hex Disassembly 1 001e MOV R0 ,R30 ; set display to 2 2 361f MOV R54,R31 ; initialise mask register for sign bit test 3 2021 MOV R32,R33 ; set candidate prime p=3 4 3c22 MOV R60,R34 ; the trial divisor q is stored in the adder as its ; negative: here it is initialised to -1, i.e. q=1 5 3d23 MOV R61,R35 ; other summand=-2 6 3c3d MOV R60,R61 ; next trial divisor q=q+2 7 3d20 MOV R61,R32 ; move p to adder summand input a, which holds remainder 8 3924 MOV R57,R36 ; for the first time round the loop, set the target ; for the branch if subtraction gives zero to 20: this ; detects the case p==q, which means we have done all ; the trial divisors and p is prime 9 3725 MOV R55,R37 ; if subtraction result non-zero, target is 1310 383d MOV R56,R61 ; test a-q11 3f38 MOV R63,R56 ; branch to selected target12 3d3d MOV R61,R61 ; a-=q13 3d3d MOV R61,R61 ; a-=q (continuing here if subtraction result not zero)14 353d MOV R53,R61 ; move a-q to and-not register to check sign15 3926 MOV R57,R38 ; target is 9 if a-q positive (round subtraction loop ; again)16 3727 MOV R55,R39 ; else target is 5 (q does not divide p, so try next q)17 3836 MOV R56,R54 ; test a-q AND 0x800018 3f38 MOV R63,R56 ; branch to selected target19 3928 MOV R57,R40 ; reset target for other branch to 21 (a zero result ; from the subtraction now indicates q properly ; divides p and so p is composite)20 0020 MOV R0 ,R32 ; p is prime: write it to the display21 3d20 MOV R61,R32 ; move p to adder22 3c1e MOV R60,R30 ; other summand=223 3f29 MOV R63,R41 ; goto 4 to try new p24 203d MOV R32,R61 ; p+=225 ; unused26 ; unused27 ; unused28 ; unused29 ; unused30 0002 ; constant 231 7fff ; constant mask for sign bit testing32 0005 ; current candidate p33 0003 ; constant 334 fffe ; constant -135 fffd ; constant -236 0014 20 ; branch target: trial divisor q equal to candidate p, ; and hence prime found37 000d 13 ; branch target: trial divisor q less than candidate p38 0009 9 ; branch target: more subtractions to do39 0005 5 ; branch target: next trial divisor q40 0015 21 ; branch target: subtraction gave zero, so p composite41 0004 4 ; branch target: next candidate p42 fffc ; constant -3


网友艾比斯[100以内的质数]如何编程求解 100 以内的质数?给出的答复:
我去…………能见到的语言基本都齐活儿了…………
貌似没人说Matlab??

primes(100)


网友skaic[100以内的质数]如何编程求解 100 以内的质数?给出的答复:
php 大法好!

echo "2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97";


网友zoick[100以内的质数]如何编程求解 100 以内的质数?给出的答复:
Matlab大法好!

clear
t=1;
for i=1:100
for j=1:i
if (round(i/j)==(i/j)&j~=1&j~=i)
break
end
end

if j==i
s(t)=i;
t=t+1;
%disp(['素数:',num2str(i)])
end
end

disp(['素数:',num2str(s)])


网友曹酌中[100以内的质数]如何编程求解 100 以内的质数?给出的答复:

prime.o: file format elf32-i386Disassembly of section .text:00000000 <main>: 0:55 push %ebp 1:89 e5 mov %esp,%ebp 3:83 e4 f0 and $0xfffffff0,%esp 6:83 ec 20 sub $0x20,%esp 9:c7 44 24 18 02 00 00 movl $0x2,0x18(%esp) 10:00 11:eb 3e jmp 51 <main+0x51> 13:8b 44 24 18 mov 0x18(%esp),%eax 17:8b 04 85 00 00 00 00 mov 0x0(,%eax,4),%eax 1e:85 c0 test %eax,%eax 20:75 2a jne 4c <main+0x4c> 22:8b 44 24 18 mov 0x18(%esp),%eax 26:01 c0 add %eax,%eax 28:89 44 24 1c mov %eax,0x1c(%esp) 2c:eb 17 jmp 45 <main+0x45> 2e:8b 44 24 1c mov 0x1c(%esp),%eax 32:c7 04 85 00 00 00 00 movl $0x1,0x0(,%eax,4) 39:01 00 00 00 3d:8b 44 24 18 mov 0x18(%esp),%eax 41:01 44 24 1c add %eax,0x1c(%esp) 45:83 7c 24 1c 63 cmpl $0x63,0x1c(%esp) 4a:7e e2 jle 2e <main+0x2e> 4c:83 44 24 18 01 addl $0x1,0x18(%esp) 51:83 7c 24 18 63 cmpl $0x63,0x18(%esp) 56:7e bb jle 13 <main+0x13> 58:c7 44 24 18 02 00 00 movl $0x2,0x18(%esp) 5f:00 60:eb 28 jmp 8a <main+0x8a> 62:8b 44 24 18 mov 0x18(%esp),%eax 66:8b 04 85 00 00 00 00 mov 0x0(,%eax,4),%eax 6d:85 c0 test %eax,%eax 6f:75 14 jne 85 <main+0x85> 71:8b 44 24 18 mov 0x18(%esp),%eax 75:89 44 24 04 mov %eax,0x4(%esp) 79:c7 04 24 00 00 00 00 movl $0x0,(%esp) 80:e8 fc ff ff ff call 81 <main+0x81> 85:83 44 24 18 01 addl $0x1,0x18(%esp) 8a:83 7c 24 18 63 cmpl $0x63,0x18(%esp) 8f:7e d1 jle 62 <main+0x62> 91:c9 leave 92:c3 ret 


网友Milo Yip[100以内的质数]如何编程求解 100 以内的质数?给出的答复:
我尝试用一行C++11代码模仿 @大人 的 Python式实现:

copy_if(range(2, 101), ostream_iterator<int>(cout, " "), [](int x){ return none_of(range(2, x), [x](int y) { return x % y == 0; }); });


网友蒙面大侠[100以内的质数]如何编程求解 100 以内的质数?给出的答复:
Haskell 也来玩耍

primes :: (Integral a) => [a] -> [a]
primes (p:xs) = p:primes [x | x <- xs , x `mod` p /= 0]

->primes [2 .. 100]


网友蒙面大侠[100以内的质数]如何编程求解 100 以内的质数?给出的答复:
JavaScript 大法好!

$.get('/question/26477210/answer/32917478').then(function(html){ console.log(JSON.parse($(html).find('blockquote')[0].lastChild.textContent)) })


网友夜了个喵[100以内的质数]如何编程求解 100 以内的质数?给出的答复:

print prime under 100 Brainf**k impl>>++[<+++++[<+++++>-]>-]<<.>>++++[<++++++++>-]<.<+.>.>>>+++++[<+++++[<++++>-]>-]<<------>+++++<[>>>>[-]+++[->+>+<<]>>[-<<+>>]>>+<<<<<<+[[-]<[->+>+<<]>>[-<<+>>]>>[-]<[->+>+<<]>>[-<<+>>]<<<<[->>>->+<[>-]>[-<<[->+>+<<]>>[-<<+>>]>]<<<<<]>>[->->+<<]>>[-<<+>>]+<[>-]>[->>[-]<]<<<<<<[->+>+<<]>>[-<<+>>]>>[-]<++[->+>+<<]>>[-<<+>>]<[-<<<->>>]<<<]>>>>>>[<<<<<<<[->+>+<<]>>[-<<+>>]>[-]++++++++++>[-]++++++++++<<<[->>>->+<[>-]>[-<<[->+>+<<]>>[-<<+>>]>>>+>[-]-<<<]>>>+<<<<<<<<]>>>>>>>[++++++++++++++++++++++++++++++++++++++++++++++++.[-]]>++++++++++++++++++++++++++++++++++++++++++++++++.[-]<<<<<<<<<<<.>>>>>>>>>-]<<<<<<<++<--]


网友钟颖cyanzhong[100以内的质数]如何编程求解 100 以内的质数?给出的答复:
这个时候当然要祭出正则表达式求素数的版本。

(1 x ++$_) =~ /^1?$|^(11+?)\1+$/ || print "$_\n" while $_ < 100


网友蒙面大侠[100以内的质数]如何编程求解 100 以内的质数?给出的答复:
MATLAB大法好!

primes(100)


网友蒙面大侠[100以内的质数]如何编程求解 100 以内的质数?给出的答复:
Python 也试试?

In [1]: print filter( lambda x: len(filter(lambda y: x%y == 0,range(2,x-1))) == 0 , range(2,101) )
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]


网友寒风[100以内的质数]如何编程求解 100 以内的质数?给出的答复:

推荐个文章吧:

求质数算法的N种境界(N > 10)
好了,现在更新个并行计算的版本,利用MPI。有没有mapreduce也来PK一下,当然不许欺负我机器烂!!
#include <mpi.h>#include <math.h>#include <stdlib.h>#include <stdio.h>#define BLOCK_LOW(id,p,n) ((id)*(n)/(p))#define BLOCK_HIGH(id,p,n) (BLOCK_LOW((id)+1,p,n)-1)int main(int argc, char **argv){ int count; //local prime count double elapse_time; //parallel execution time int first; //index of first multiple int global_count; //global prime count int high_value; //highest value on this proc int i; int id; //process ID number int index; //index of current prime int low_value; //lowest value on this proc char *marked; //portion of 2,...,'n' int n; int p; //number of processed int proc0_size; //size of the 0's sbuarray int prime; //current prime int size; //elements in 'marked' MPI_Init(&argc, &argv); MPI_Barrier(MPI_COMM_WORLD); elapse_time = - MPI_Wtime(); MPI_Comm_rank(MPI_COMM_WORLD, &id); MPI_Comm_size(MPI_COMM_WORLD, &p); if(argc != 2) { if(!id) { printf("Command line: %s <m>\n", argv[0]); } MPI_Finalize(); exit(1); } n = atoi(argv[1]); low_value = 2 + BLOCK_LOW(id, p, n-1); high_value = 2 + BLOCK_HIGH(id, p, n-1); size = high_value-low_value+1; proc0_size = (n-1)/p; if((2+proc0_size) < (int)sqrt((double)n)) { if(!id) { printf("Too many processes\n"); } MPI_Finalize(); exit(1); } marked = (char*) malloc(size); if(marked == NULL) { printf("Cannot allocate enough memory\n"); MPI_Finalize(); exit(1); } for(i=0; i<size; i++) { marked[i]=0; } if(!id) { index = 0; } prime = 2; do { if(prime * prime > low_value) { first = prime * prime - low_value; } else { if(!(low_value%prime)) { first = 0; } else { first = prime-(low_value%prime); } } for(i=first; i<size; i+=prime) { marked[i] = 1; } if(!id) { while(marked[++index]); prime = index+2; } MPI_Bcast(&prime, 1, MPI_INT, 0, MPI_COMM_WORLD); } while(prime*prime <= n); count = 0; for(i=0; i<size; i++) { if(!marked[i]) { count++; } } MPI_Reduce(&count,&global_count,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD); elapse_time += MPI_Wtime(); if(!id) { printf("%d primes are less than or equal to %d\n",global_count,n); printf("Total elapsed time: %10.6f\n", elapse_time); } MPI_Finalize(); return 0;}


网友蒙面大侠[100以内的质数]如何编程求解 100 以内的质数?给出的答复:

Cases[Range[100], x_?PrimeQ]


网友程祥[100以内的质数]如何编程求解 100 以内的质数?给出的答复:
何不用Excel的VBA来一发?
sub 给老子打质数()
n=inputbox("客官想要多少以内的质数?(记得大于3哦)")
m=1
for i=3 to n
if laozishizhishu(i) then
cells(m,1)=i
m=m+1
end if
next
end sub

function laozishizhishu(x)
for k=2 to sqr(x)
if x mod k =0 then
laozishizhishu=false
exit function
end if
next
laozishizhishu=true
end function
测试效果
输入一个数输入一个数
收工收工


网友高德纳[100以内的质数]如何编程求解 100 以内的质数?给出的答复:
提供一个 Ruby 版供参考

print (2..100).select {|n| (2..(n + 1) / 2).all? {|d| n % d >0}}


网友cholerae[100以内的质数]如何编程求解 100 以内的质数?给出的答复:
fn main() {
println!("2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97");
}
rust大法好


网友AlephAlpha[100以内的质数]如何编程求解 100 以内的质数?给出的答复:
我用 GNU Octave:

primes(100)


网友蒙面大侠[100以内的质数]如何编程求解 100 以内的质数?给出的答复:
bash大法:

-----文件----
#!/bin/sh

echo "2 3 5 7 11 13 17 19 23 29 3137 41 43 47 53 59 61 67 71 73 79 83 89 97"



-----文件结束-----


网友李明[100以内的质数]如何编程求解 100 以内的质数?给出的答复:

pascal:var a:array [1..100] of integer; i,j,k:integer;begin for i:=1 to 100 do a[i]:=i; a[1]:=0;i:=2; while i<=100 do begin k:=i; while k<=100 do begin k:=k+i; a[k]:=0; end; {————上面将所有a[i]的倍数清0} i:=i+1; while a[i]=0 do i:=i+1; {————查找接下来的第一个非0数} end; for i:=1 to 100 do if a[i]<>0 then write(a[i],' ');end. -----------------------------------------------------------------------------------8086:data segmentD1 DW 200 DUP(0);定义数组data endscode segmentmain proc farassume cs:code,ds:datastart:push dsxor ax,axpush axMOV AX,DATAMOV DS,AXMOV DX,1MOV SI,OFFSET D1NEXT:INC DX;ADD SI,2CMP DX,100;100以内的数JAE EXITMOV AX,DXSHR AX,1;/2DEC AXMOV CX,AXMOV BL,1LOOP1:INC BL;2,3,....MOV AX,DXDIV BLCMP AH,0JE NEXT;余数为0,非素数LOOP LOOP1MOV [SI],DX;保存素数ADD SI,2JMP NEXTEXIT:RETmain endpcode endsend start

四 : 1-100以内的质数理解记忆顺口溜

1-100以内的质数理解记忆顺口溜

一位质数偶打头,2、3、5、7要记熟;  (  2、3、5、7)
两位质数不用愁,可以编成顺口溜。(www.61k.com)
十位若是4和1,个位准有1、3、7;  ( 41、43、47、11、13、17)
十位若是2、5、8,个位3、9往上加;  ( 23、29、53、59、83、89)
十位若是3和6,个位1、7跟在后;        (31、37、61、67)
十位若是被7占,个位准是1、9、3;      (71、79、73)
19、97最后算。                            (19、97)
100以内质数顺口溜
    二、三、五、七、一十一
  十三、十七、一十九
    二三九、三一七
    五三九、六一七
    四一三七、七一三九
    八三、八九、九十七

2、3、5、7要牢记,
 1、3、7、9是十几,
二、五、八十跟3、9,
 三十、六十带1、7,
四十1、3、7,
  七十1、3、9,

最后还有97。

二 三 五 七 一十一
一三 一七 一十九
二三 二九 三十一
三七 四一 四十三
四七 五三 五十九
六一 六七 七十一
七三 七九 八十三
还有八九 九十七

2、3、5、7和11,
 13后面是17,
 19、23、29,(十九、二三、二十九)
31、37、41,(三一、三七、四十一) 
43、47、53,(四三、四七、五十三) 
59、61、67,(五九、六一、六十七) 
71、73、79,(七一、七三、七十九) 
83、89、97。(八三、八九、九十七)

25个质数不能少;
百以内质数心中记。

本文由论文联盟 www.61k.com 收集整理

本文标题:100以内的质数-100以内质数口诀
本文地址: http://www.61k.com/1069026.html

61阅读| 精彩专题| 最新文章| 热门文章| 苏ICP备13036349号-1