0

Write a program for generating prime numbers in python

please write a simple code

7th Jan 2018, 5:03 PM
J Prasad Rao
J Prasad Rao - avatar
5 Respuestas
+ 8
#include<stdio.h>   int main(){     int n,i,m=0,flag=0;     printf("Enter the number to check prime:");    scanf("%d",&n);    m=n/2;     for(i=2;i<=m;i++)     {    if(n%i==0)     {     printf("Number is not prime");     flag=1;     break;     }     }     if(flag==0)     printf("Number is prime");      return 0;    }    
7th Jan 2018, 5:19 PM
Jaydeep Khatri
Jaydeep Khatri - avatar
+ 5
Search the Code Playground for such codes, there are a lot in the bucket already :)
7th Jan 2018, 5:16 PM
Dev
Dev - avatar
7th Jan 2018, 5:10 PM
Sebastián Zapata
Sebastián Zapata - avatar
0
please write in python only
7th Jan 2018, 5:21 PM
J Prasad Rao
J Prasad Rao - avatar
0
I recently made my 2.0 version of my previous code xD, it needs less operations, but it's less simple to understand I guess. https://code.sololearn.com/c38NGLZvSBiP/?ref=app
7th Jan 2018, 5:22 PM
Sebastián Zapata
Sebastián Zapata - avatar