If yougotta have youa c____...

1. I have great ________in you. I know you’ll do well. 2. As the couple had no children of their o_百度知道
1. I have great ________in you. I know you’ll do well. 2. As the couple had no children of their o
1. —The weather has been very hot and dry.
—Yes. If it had rained even a drop, things would be much better now! And my vegetables ______. 【2010北京高考】
A. wouldn't die
B. didn't die
C. hadn't died
D. wouldn't have died 2. But for the help of my English teacher, I ______ the first prize in the English Writing Competition.
【2009福建高考】A. would not win
B. would not have won
C. would win
D. would have won
3. I told your friend how to get to the hotel, but perhaps I ______ have driven her there. A. could
D. should4. There was a lot of fun at yesterday’s party. You ______ come, but why didn’t you?A. must have
C. need have
D. ought to have 5. He is suffering so much now. If only he ______ quietly as the doctor instructed.
C. had lain
D. should lie6. “Mary looks hot and dry”
“So _____ you if you had so high a fever.”A. do
D. would7. ______ smoking, he would not have got cancer in the lung.A. Was he given up
B. Had he given up
C. Did he give
D. If he gave up8. — Catherine, I have cleaned the room for you. — Thanks. You ______ it. I could manage it myself. A. needn’t do
B. needn’t have done
C. mustn’t do
D. shouldn’t have done 9. This pr缉发光菏叱孤癸酞含喀inter is of good quality. If it _____ break down within the first year, we would repair it at our expense.
D. might10. If we ______ a quick action, things would be quite different now.
B. had taken
C. should take
D. will tak
提问者采纳
  1. I have great _confidence_______in you. I know you’ll do well. 2. As the couple had no children of their own  1. —The weather has been very hot and dry.  —Yes. If it had rained even a drop, things would be much better now! And my vegetables __D____. 【2010北京高考】  A. wouldn't die
B. didn't die
C. hadn't died
D. wouldn't have died  2. But for the help of my English teacher, I _B_____ the first prize in the English Writing Competition.
【2009福建高考】  A. would not win
B. would not have won
C. would win
D. would have won  3. I told your friend how to get to the hotel, but perhaps I __D____ have driven her there.  A. could
D. should  4. There was a lot of fun at yesterday’s party. You __D____ come, but why didn’t you?  A. must have
C. need have
D. ought to have  5. He is suffering so much now. If only he _D_____ quietly as the doctor instructed.  A. lies
C. had lain
D. should lie  6. “Mary looks hot and dry”
“So __D___ you if you had so high a fever.”  A. do
D. would  7. _B_____ smoking, he would not have got cancer in the lung.  A. Was he given up
B. Had he given up
C. Did he give
D. If he gave up  8. — Catherine, I have cleaned the room f缉发光菏叱孤癸酞含喀or you.  — Thanks. You _B_____ it. I could manage it myself.  A. needn’t do
B. needn’t have done
C. mustn’t do
D. shouldn’t have done  9. This printer is of good quality. If it __B___ break down within the first year, we would repair it at our expense.  A. would
D. might  10. If we _B_____ a quick action, things would be quite different now.  A. took
B. had taken
C. should take
D. will tak
提问者评价
thank 不过还有。。
其他类似问题
为您推荐:
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁Wrapping a C library in Python: C, Cython or ctypes? - Stack Overflow
to customize your list.
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
J it only takes a minute:
Join the Stack Overflow community to:
Ask programming questions
Answer and help your peers
Get recognized for your expertise
I want to call a C library from a Python application. I don't want to wrap the whole API, only the functions and datatypes that are relevant to my case. As I see it, I have three choices:
Create an actual extension module in C. Probably overkill, and I'd also like to avoid the overhead of learning extension writing.
to expose the relevant parts from the C library to Python.
Do the whole thing in Python, using
to communicate with the external library.
I'm not sure whether 2) or 3) is the better choice. The advantage of 3) is that ctypes is part of the standard library, and the resulting code would be pure Python & although I'm not sure how big that advantage actually is.
Are there more advantages / disadvantages with either choice? Which approach do you recommend?
Edit: Thanks for all your answers, they provide a good resource for anyone looking to do something similar. The decision, of course, is still to be made for the single case&there's no one "This is the right thing" sort of answer. For my own case, I'll probably go with ctypes, but I'm also looking forward to trying out Cython in some other project.
With there being no single true answer, accepting one i I chose FogleBird's answer as it provides some good insight into ctypes and it currently also is the highest-voted answer. However, I suggest to read all the answers to get a good overview.
Thanks again.
24.7k982112
ctypes is your best bet for getting it done quickly, and it's a pleasure to work with as you're still writing Python!
I recently wrapped an
driver for communicating with a USB chip using ctypes and it was great.
I had it all done and working in less than one work day. (I only implemented the functions we needed, about 15 functions).
We were previously using a third-party module, , for the same purpose.
PyUSB is an actual C/Python extension module.
But PyUSB wasn't releasing the GIL when doing blocking reads/writes, which was causing problems for us.
So I wrote our own module using ctypes, which does release the GIL when calling the native functions.
One thing to note is that ctypes won't know about #define constants and stuff in the library you're using, only the functions, so you'll have to redefine those constants in your own code.
Here's an example of how the code ended up looking (lots snipped out, just trying to show you the gist of it):
from ctypes import *
d2xx = WinDLL('ftd2xx')
INVALID_HANDLE = 1
DEVICE_NOT_FOUND = 2
DEVICE_NOT_OPENED = 3
def openEx(serial):
serial = create_string_buffer(serial)
handle = c_int()
if d2xx.FT_OpenEx(serial, OPEN_BY_SERIAL_NUMBER, byref(handle)) == OK:
return Handle(handle.value)
raise D2XXException
class Handle(object):
def __init__(self, handle):
self.handle = handle
def read(self, bytes):
buffer = create_string_buffer(bytes)
count = c_int()
if d2xx.FT_Read(self.handle, buffer, bytes, byref(count)) == OK:
return buffer.raw[:count.value]
raise D2XXException
def write(self, data):
buffer = create_string_buffer(data)
count = c_int()
bytes = len(data)
if d2xx.FT_Write(self.handle, buffer, bytes, byref(count)) == OK:
return count.value
raise D2XXException
Someone did
on the various options.
I might be more hesitant if I had to wrap a C++ library with lots of classes/templates/etc.
But ctypes works well with structs and can even
into Python.
33.8k1283112
Warning: a Cython core developer's opinion ahead.
I almost always recommend Cython over ctypes. The reason is that it has a much smoother upgrade path. If you use ctypes, many things will be simple at first, and it's certainly cool to write your FFI code in plain Python, without compilation, build dependencies and all that. However, at some point, you will almost certainly find that you have to call into your C library a lot, either in a loop or in a longer series of interdependent calls, and you would like to speed that up. That's the point where you'll notice that you can't do that with ctypes. Or, when you need callback functions and you find that your Python callback code becomes a bottleneck, you'd like to speed it up and/or move it down into C as well. Again, you cannot do that with ctypes. So you have to switch languages at that point and start rewriting parts of your code, potentially reverse engineering your Python/ctypes code into plain C, thus spoiling the whole benefit of writing your code in plain Python in the first place.
With Cython, OTOH, you're completely free to make the wrapping and calling code as thin or thick as you want. You can start with simple calls into your C code from regular Python code, and Cython will translate them into native C calls, without any additional calling overhead, and with an extremely low conversion overhead for Python parameters. When you notice that you need even more performance at some point where you are making too many expensive calls into your C library, you can start annotating your surrounding Python code with static types and let Cython optimise it straight down into C for you. Or, you can start rewriting parts of your C code in Cython in order to avoid calls and to specialise and tighten your loops algorithmically. And if you need a fast callback, just write a function with the appropriate signature and pass it into the C callback registry directly. Again, no overhead, and it gives you plain C calling performance. And in the much less likely case that you really cannot get your code fast enough in Cython, you can still consider rewriting the truly critical parts of it in C (or C++ or Fortran) and call it from your Cython code naturally and natively. But then, this really becomes the last resort instead of the only option.
So, ctypes is nice to do simple things and to quickly get something running. However, as soon as things start to grow, you'll most likely come to the point where you notice that you'd better used Cython right from the start.
Cython is a pretty cool tool in itself, well worth learning, and is surprisingly close to the Python syntax. If you do any scientific computing with Numpy, then Cython is the way to go because it integrates with Numpy for fast matrix operations.
Cython is a superset of Python language. You can throw any valid Python file at it, and it will spit out a valid C program. In this case, Cython will just map the Python calls to the underlying CPython API. This results in perhaps a 50% speedup because your code is no longer interpreted.
To get some optimizations, you have to start telling Cython additional facts about your code, such as type declarations. If you tell it enough, it can boil the code down to pure C. That is, a for loop in Python becomes a for loop in C. Here you will see massive speed gains. You can also link to external C programs here.
Using Cython code is also incredibly easy. I thought the manual makes it sound difficult. You literally just do:
$ cython mymodule.pyx
$ gcc [some arguments here] mymodule.c -o mymodule.so
and then you can import mymodule in your Python code and forget entirely that it compiles down to C.
In any case, because Cython is so easy to setup and start using, I suggest trying it to see if it suits your needs. It won't be a waste if it turns out not to be the tool you're looking for.
32.7k114970
For calling a C library from a Python application there is also
which is a new alternative for ctypes. It brings a fresh look for FFI:
it handles the problem in a fascinating, clean way (as opposed to ctypes)
it doesn't require to write non Python code (as in SWIG, Cython, ...)
I'll throw another one out there:
It's easy to learn, does a lot of things right, and supports many more languages so the time spent learning it can be pretty useful.
If you use SWIG, you are creating a new python extension module, but with SWIG doing most of the heavy lifting for you.
8,03422041
Personally, I'd write an extension module in C. Don't be intimidated by Python C extensions -- they're not hard at all to write. The documentation is very clear and helpful. When I first wrote a C extension in Python, I think it took me about an hour to figure out how to write one -- not much time at all.
204k46370394
If you have already a library with a defined
API, I think ctypes is the best option, as you only have to do a little initialization and then more or less call the library the way you're used to.
I think Cython or creating an extension module in C (which is not very difficult) are more useful when you need new code, e.g. calling that library and do some complex, time-consuming tasks, and then passing the result to Python.
Another approach, for simple programs, is directly do a different process (compiled externally), outputting the result to standard output and call it with subprocess module. Sometimes it's the easiest approach.
For example, if you make a console C program that works more or less that way
$miCcode 10
You could call it from Python
&&& import subprocess
&&& p = subprocess.Popen(['miCcode', '10'], shell=True, stdout=subprocess.PIPE)
&&& std_out, std_err = p.communicate()
&&& print std_out
With a little string formating, you can take the result in any way you want. You can also capture the standard error output, so it's quite flexible.
53.6k13112173
2,87321839
is great when you've already got a compiled library blob to deal with (such as OS libraries). The calling overhead is severe, however, so if you'll be making a lot of calls into the library, and you're going to be writing the C code anyway (or at least compiling it), I'd say to go for . It's not much more work, and it'll be much faster and more pythonic to use the resulting pyd file.
I personally tend to use cython for quick speedups of python code (loops and integer comparisons are two areas where cython particularly shines), and when there is some more involved code/wrapping of other libraries involved, I'll turn to . Boost.Python can be finicky to set up, but once you've got it working, it makes wrapping C/C++ code straightforward.
cython is also great at wrapping
(which I learned from the ), but I haven't used numpy, so I can't comment on that.
10.1k52848
There is one issue which made me use ctypes and not cython and which is not mentioned in other answers.
Using ctypes the result does not depend on compiler you are using at all. You may write a library using more or less any language which
may be compiled to native shared library. It does not matter much, which system, which language and which compiler. Cython, however, is limited by the infrastructure. E.g, if you want to use intel compiler on windows, it is much more tricky to make cython work: you should "explain" compiler to cython, recompile something with this exact compiler, etc. Which significantly limits portability.
There's also one possibility to use
for libraries that are using .
15.5k75062
If you are targeting Windows and choose to wrap some proprietary C++ libraries, then you may soon discover that different versions of msvcrt***.dll (Visual C++ Runtime) are slightly incompatible.
This means that you may not be able to use
since resulting wrapper.pyd is linked against msvcr90.dll (Python 2.7) or msvcr100.dll (Python 3.x). If the library that you are wrapping is linked against different version of runtime, then you're out of luck.
Then to make things work you'll need to create C wrappers for C++ libraries, link that wrapper dll against the same version of msvcrt***.dll as your C++ library. And then use
to load your hand-rolled wrapper dll dynamically at the runtime.
So there are lots of small details, which are described in great detail in following article:
"Beautiful Native Libraries (in Python)":
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
The week's top questions and answers
Important community announcements
Questions that need answers
By subscribing, you agree to the
Stack Overflow works best with JavaScript enabledc# - C - determine if a number is prime - Stack Overflow
to customize your list.
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
J it only takes a minute:
Join the Stack Overflow community to:
Ask programming questions
Answer and help your peers
Get recognized for your expertise
I am trying to come up with a method that takes an integer and returns a boolean to say if the number is prime or not and I don't know much C; would anyone care to give me some pointers?
Basically, I would do this in C# like this:
static bool IsPrime(int number)
for (int i = 2; i & i++)
if (number % i == 0 && i != number)
5,069104569
OK, so forget about C.
Suppose I give you a number and ask you to determine if it's prime.
How do you do it?
Write down the steps clearly, then worry about translating them into code.
Once you have the algorithm determined, it will be much easier for you to figure out how to write a program, and for others to help you with it.
edit: Here's the C# code you posted:
static bool IsPrime(int number) {
for (int i = 2; i & i++) {
if (number % i == 0 && i != number)
This is very nearly valid C there's no bool type in C, and no true or false, so you need to modify it a little bit (edit: Kristopher Johnson correctly points out that C99 added the stdbool.h header).
Since some people don't have access to a C99 environment (but you should use one!), let's make that very minor change:
int IsPrime(int number) {
for (i=2; i& i++) {
if (number % i == 0 && i != number) return 0;
This is a perfectly valid C program that does what you want.
We can improve it a little bit without too much effort.
First, note that i is always less than number, so the check that i != number we can get rid of it.
Also, you don't actually need to try divisors all the way up to number - 1; you can stop checking when you reach sqrt(number).
Since sqrt is a floating-point operation and that brings a whole pile of subtleties, we won't actually compute sqrt(number).
Instead, we can just check that i*i &= number:
int IsPrime(int number) {
for (i=2; i*i&= i++) {
if (number % i == 0) return 0;
One last thing, there was a small bug in your original algorithm!
If number is negative, or zero, or one, this function will claim that the number is prime.
You likely want to handle that properly, and you may want to make number be unsigned, since you're more likely to care about positive values only:
int IsPrime(unsigned int number) {
if (number &= 1) return 0; // zero and one are not prime
for (i=2; i*i&= i++) {
if (number % i == 0) return 0;
This definitely isn't the fastest way to check if a number is prime, but it works, and it's pretty straightforward.
We barely had to modify your code at all!
74.3k11122211
I'm suprised that no one mentioned this.
Basically nonprime numbers are divisible by another number besides 1 and themselves
Therefore: a nonprime number will be a product of prime numbers.
The sieve of Eratosthenes finds a prime number and stores it. When a new number is checked for primeness all of the previous primes are checked against the know prime list.
This algorithm/problem is known as ""
It creates a collection of prime numbers
Its an example of a dynamic programming problem
Its quick!
9,670651100
Build a table of small primes, and check if they divide your input number.
If the number survived to 1, try pseudo primality tests with increasing basis. See
for example.
If your number survived to 2, you can conclude it is prime if it is below some well known bounds. Otherwise your answer will only be "probably prime". You will find some values for these bounds in the wiki page.
6,74211523
Stephen Canon answered it very well!
The algorithm can be improved further by observing that all primes are of the form 6k ± 1, with the exception of 2 and 3.
This is because all integers can be expressed as (6k + i) for some integer k and for i = -1, 0, 1, 2, 3, or 4; 2 divides (6k + 0), (6k + 2), (6k + 4); and 3 divides (6k + 3).
So a more efficient method is to test if n is divisible by 2 or 3, then to check through all the numbers of form 6k ± 1 ≤ √n.
This is 3 times as fast as testing all m up to √n.
int IsPrime(unsigned int number) {
if (number &= 3 && number & 1)
// as 2 and 3 are prime
else if (number%2==0 || number%3==0)
// check if number is divisible by 2 or 3
for (i=5; i*i&= i+=6) {
if (number % i == 0 || number%(i + 2) == 0)
Check the modulus of each integer from 2 up to the root of the number you're checking.
If modulus equals zero then it's not prime.
pseudo code:
bool IsPrime(int target)
for (i = 2; i &= root(target); i++)
if ((target mod i) == 0)
55.6k1070134
I would just add that no even number (bar 2) can be a prime number. This results in another condition prior to for loop. So the end code should look like this:
int IsPrime(unsigned int number) {
if (number &= 1) return 0; // zero and one are not prime
if ((number & 2) && ((number % 2) == 0)) return 0; //no even number is prime number (bar 2)
for (i=2; i*i&= i++) {
if (number % i == 0) return 0;
1,07911330
this program is much efficient for checking a single number for primality check.
bool check(int n){
if (n &= 3) {
return n & 1;
if (n % 2 == 0 || n % 3 == 0) {
int sq=sqrt(n); //include math.h or use i*i&n in for loop
for (int i = 5; i&= i += 6) {
if (n % i == 0 || n % (i + 2) == 0) {
1,42011228
int is_prime(int val)
if (val==2) return TRUE;
/* 2 is prime */
if ((val&1)==0) return FALSE;
/* any other even number is not */
while (square&val)
if (val % div == 0) return FALSE;
/* evenly divisible */
square=div*
if (square==val) return FALSE;
return TRUE;
Handling of 2 and even numbers are kept out of the main loop which only handles odd numbers divided by odd numbers. This is because an odd number modulo an even number will always give a non-zero answer which makes those tests redundant. Or, to put it another way, an odd number may be evenly divisible by another odd number but never by an even number (E*E=>E, E*O=>E, O*E=>E and O*O=>O).
A division/modulus is really costly on the x86 architecture although how costly varies (see ). Multiplications on the other hand are quite cheap.
After reading this question, I was intrigued by the fact that some answers offered optimization by running a loop with multiples of 2*3=6.
So I create a new function with the same idea, but with multiples of 2*3*5=30.
int check235(unsigned long n)
unsigned long sq,
if(n&=3||n==5)
return n&1;
if(n%2==0 || n%3==0 || n%5==0)
sq=ceil(sqrt(n));
for(i=7; i&= i+=30)
if (n%i==0 || n%(i+4)==0 || n%(i+6)==0 || n%(i+10)==0 || n%(i+12)==0
|| n%(i+16)==0 || n%(i+22)==0 || n%(i+24)==0)
By running both functions and checking times I could state that this function is really faster. Lets see 2 tests with 2 different primes:
$ time ./testprimebool.x
Yes, its prime.
$ time ./testprimebool.x
Yes, its prime.
$ time ./testprimebool.x
Yes, its prime.
$ time ./testprimebool.x
Yes, its prime.
So I thought, would someone gain too much if generalized? I came up with a function that will do a siege first to clean a given list of primordial primes, and then use this list to calculate the bigger one.
int checkn(unsigned long n, unsigned long *p, unsigned long t)
unsigned long sq, i, j, qt=1, rt=0;
unsigned long *q, *r;
for(i=0; i&t; i++)
if(n%p[i]==0)
if((q=calloc(qt, sizeof(unsigned long)))==NULL)
perror("q=calloc()");
for(i=0; i&t; i++)
for(j=p[i]-2; j& j+=p[i])
for(j=0; j& j++)
if((r=malloc(sizeof(unsigned long)*rt))==NULL)
perror("r=malloc()");
for(j=0; j& j++)
r[i++]=j+1;
sq=ceil(sqrt(n));
for(i=1; i&= i+=qt+1)
if(i!=1 && n%i==0)
for(j=0; j& j++)
if(n%(i+r[j])==0)
I assume I did not optimize the code, but it's fair. Now, the tests. Because so many dynamic memory, I expected the list 2 3 5 to be a little slower than the 2 3 5 hard-coded. But it was ok as you can see bellow. After that, time got smaller and smaller, culminating the best list to be:
2 3 5 7 11 13 17 19
With 8.6 seconds. So if someone would create a hardcoded program that makes use of such technique I would suggest use the list 2 3 and 5, because the gain is not that big. But also, if willing to code, this list is ok. Problem is you cannot state all cases without a loop, or your code would be very big (There would be 1658879 ORs, that is || in the respective internal if). The next list:
2 3 5 7 11 13 17 19 23
time started to get bigger, with 13 seconds. Here the whole test:
$ time ./testprimebool.x
Yes, its prime.
$ time ./testprimebool.x
f(2,3,5,7)
Yes, its prime.
$ time ./testprimebool.x
f(2,3,5,7,11)
Yes, its prime.
$ time ./testprimebool.x
3 5 7 11 13
f(2,3,5,7,11,13)
Yes, its prime.
$ time ./testprimebool.x
3 5 7 11 13 17
f(2,3,5,7,11,13,17)
Yes, its prime.
$ time ./testprimebool.x
3 5 7 11 13 17 19
f(2,3,5,7,11,13,17,19)
Yes, its prime.
$ time ./testprimebool.x
3 5 7 11 13 17 19 23
f(2,3,5,7,11,13,17,19,23)
Yes, its prime.
$ time ./testprimebool.x
3 5 7 11 13 17 19 23 29
f(2,3,5,7,11,13,17,19,23,29)
q=calloc(): Cannot allocate memory
PS. I did not free(r) intentionally, giving this task to the OS, as the memory would be freed as soon as the program exited, to gain some time. But it would be wise to free it if you intend to keep running your code after the calculation.
int check2357(unsigned long n)
unsigned long sq,
if(n&=3||n==5||n==7)
return n&1;
if(n%2==0 || n%3==0 || n%5==0 || n%7==0)
sq=ceil(sqrt(n));
for(i=11; i&= i+=210)
if(n%i==0 || n%(i+2)==0 || n%(i+6)==0 || n%(i+8)==0 || n%(i+12)==0 ||
n%(i+18)==0 || n%(i+20)==0 || n%(i+26)==0 || n%(i+30)==0 || n%(i+32)==0 ||
n%(i+36)==0 || n%(i+42)==0 || n%(i+48)==0 || n%(i+50)==0 || n%(i+56)==0 ||
n%(i+60)==0 || n%(i+62)==0 || n%(i+68)==0 || n%(i+72)==0 || n%(i+78)==0 ||
n%(i+86)==0 || n%(i+90)==0 || n%(i+92)==0 || n%(i+96)==0 || n%(i+98)==0 ||
n%(i+102)==0 || n%(i+110)==0 || n%(i+116)==0 || n%(i+120)==0 || n%(i+126)==0 ||
n%(i+128)==0 || n%(i+132)==0 || n%(i+138)==0 || n%(i+140)==0 || n%(i+146)==0 ||
n%(i+152)==0 || n%(i+156)==0 || n%(i+158)==0 || n%(i+162)==0 || n%(i+168)==0 ||
n%(i+170)==0 || n%(i+176)==0 || n%(i+180)==0 || n%(i+182)==0 || n%(i+186)==0 ||
n%(i+188)==0 || n%(i+198)==0)
$ time ./testprimebool.x
h(2,3,5,7)
Yes, its prime.
2,78612141
Using Sieve of Eratosthenes, computation is quite faster compare to "known-wide" prime numbers algorithm.
By using pseudocode from it's wiki (), I be able to have the solution on C#.
public bool IsPrimeNumber(int val) {
// Using Sieve of Eratosthenes.
if (val & 2)
// Reserve place for val + 1 and set with true.
var mark = new bool[val + 1];
for(var i = 2; i &= i++)
// Iterate from 2 ... sqrt(val).
for (var i = 2; i &= Math.Sqrt(val); i++)
if (mark[i])
// Cross out every i-th number in the places after i (all the multiples of i).
for (var j = (i * i); j &= j += i)
return mark[val];
IsPrimeNumber() takes 21s 758ms.
NOTE: Value might vary depend on hardware specifications.
Concept is every prime number except 2 and 3 is of the form (6n-1) or (6n+1)
int isprime(int n)
if(n == 2 || n == 3) return 1;
if(n % 2 == 0 || n % 3 == 0) return 0;
for(int i=5; i*i & i+=6)
if(n % i == 0 || n % (i + 2) == 0) return 0;
If number is not prime then return 0
else return 1
6,33331240
protected by ♦
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10
on this site (the ).
Would you like to answer one of these
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled}

我要回帖

更多关于 if you have time 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信