1. 程式人生 > >輸出1-100中能被3整除但不能被5整除的數,並統計這樣的數有多少個

輸出1-100中能被3整除但不能被5整除的數,並統計這樣的數有多少個

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int i,count=0;
            for (i = 1; i <= 100; i++) {
                if (i % 3 == 0 && i % 5 != 0) {
                    Console.Write(i+"  ");
                    count++;
                }
                
            }
            Console.WriteLine("一共有"+count);
                Console.ReadKey();

        }
    }
}