1. 程式人生 > >The blog of CSDN in 楊天福

The blog of CSDN in 楊天福

package com.zhidi.loop;

public class Zhishuhe {
    public static void main(String[] args){
        int sum=0;
        int a;
        int b;
        for(a=1;a<=100;a++){
            for(b=2;b<=a;b++){
                if(a%b==0&&a!=b){
                    break;
                }else if(a%b==0
&&a==b){ sum+=a; } } } System.out.println(sum); } }