当前位置:网站首页>Judging prime
Judging prime
2022-07-19 05:36:00 【Lun Zhi】
public static void main(String args[]){
3 //1 Neither prime nor sum , Use i from 2 Start .
4 for(int i=2;i<=1000;i++){
5 boolean flag = true;
6 for(int j = 2;j < i;j++){
7 if(i % j==0){
8 flag = false;
9 break;// here we are 1000 The prime number in , Just jump out of the loop , And output the result .
10 }
11 }
12 if(flag){
13 System.out.print(" "+i);
14 }
15 }
16 }C++
#include <stdio.h>
int main(){
int a=0; // The number of primes
int num=0; // Integer entered
printf(" Enter an integer :");
scanf("%d",&num);
for(int i=2;i<num;i++){
if(num%i==0){
a++; // Prime number plus 1
}
}
if(a==0){
printf("%d Prime number .\n", num);
}else{
printf("%d Not primes .\n", num);
}
return 0;
}
边栏推荐
猜你喜欢

Is the software testing training of lemon class reliable? This successful case of counter attack from the training class tells you

跨域和处理跨域

ETL tool -- kettle realizes simple data migration

5. Spark core programming (1)

The latest news of spring recruitment in 2022: the average salary of it Internet industry is 18500 yuan

MySQL事务

Flutter Intl的使用

聊聊并发编程的12种业务场景

4.东软跨境电商数仓项目--数据采集通道搭建之用户行为数据采集通道搭建(2022.6.1-2022.6.4)

1 SparkSQL概述
随机推荐
微信小程序的页面导航
Table field attribute query
JNI实用笔记
D3.V3.js数据可视化 -- 力导向图之图片和提示
Ambari 2.7.5 integrated installation hue 4.6
Using Flink SQL to fluidize market data 2: intraday var
C语言的宏定义
12.数据仓库搭建之ADS层搭建
2. Technology selection of Neusoft cross border e-commerce data warehouse project
Ambari2.7.5 integration es6.4.2
1.東軟跨境電商數倉需求規格說明文檔
12. Ads layer construction of data warehouse construction
MySQL -- triggers and views
时间差计算
7.数据仓库搭建之数据仓库环境准备
SnackBar源码解析及封装
配置tabBar和request网络数据请求
Mysql逗号分隔的数据进行分行
Solutions for vscode terminal failure
MySQL installation and configuration tutorial (super detailed)