C#练习题答案: 简单的数学测试【难度:1级】--景越C#经典编程题库,1000道C#基础练习题等你来挑战

这是一篇关于C#编程的基础数学测试题目集,包含10个难度为1级的问题,涵盖算法和逻辑思维,适合初学者进行练习和提升。
摘要由CSDN通过智能技术生成

简单的数学测试【难度:1级】:

答案1:

using System.Linq;

public class Kata
{
   
  public static bool[] NumberProperty(int n) =>  new bool[3]{
   IsPrime(n), n % 2 == 0, n % 10 == 0};
  private static bool IsPrime(int n) => n < 0 ? false : Enumerable.Range(1, n).Count(x => n % x == 0) == 2;
}

答案2:

using System.Collections.Generic;

public class Kata
{
   
  private static HashSet<int> primes = new HashSet<int> {
   2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1277,1279,1283,1289,1291,1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,1409,1423,1427,1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,1487,1489,1493,1499,1511,1523,1531,1543,1549,1553,1559,1567,1571,1579,1583,1597,1601,1607,1609,1613,1619,1621,1627,1637,1657,1663,1667,1669,1693,1697,1699,1709,1721,1723,1733,1741,1747,1753,1759,1777,1783,1787,1789,1801,1811,1823,1831,1847,1861,1867,1871,1873,1877,1879,1889,1901,1907,1913,1931,1933,1949,1951,1973,1979,1987,1993,1997,1999,2003,2011,2017,2027,2029,2039,2053,2063,2069,2081,2083,2087,2089,2099,2111,2113,2129,2131,2137,2141,2143,2153,2161,2179,2203,2207,2213,2221,2237,2239,2243,2251,2267,2269,2273,2281,2287,2293,2297,2309,2311,2333,2339,2341,2347,2351,2357,2371,2377,2381,2383,2389,2393,2399,2411,2417,2423,2437,2441,2447,2459,2467,2473,2477,2503,2521,2531,2539,2543,2549,2551,2557,2579,2591,2593,2609,2617,2621,2633,2647,2657,2659,2663,2671,2677,2683,2687,2689,2693,2699,2707,2711,2713,2719,2729,2731,2741,2749,2753,2767,2777,2789,2791,2797,2801,2803,2819,2833,2837,2843,2851,2857,2861,2879,2887,2897,2903,2909,2917,2927,2939,2953,2957,2963,2969,2971,2999,3001,3011,3019,3023,3037,3041,3049,3061,3067,3079,3083,3089,3109,3119,3121,3137,3163,3167,3169,3181,3187,3191,3203,3209,3217,3221,3229,3251,3253,3257,3259,3271,3299,3301,3307,3313,3319,3323,3329,3331,3343,3347,3359,3361,3371,3373,3389,3391,3407,3413,3433,3449,3457,3461,3463,3467,3469,3491,3499,3511,3517,3527,3529,3533,3539,3541,3547,3557,3559,3571,3581,3583,3593,3607,3613,3617,3623,3631,3637,3643,3659,3671,3673,3677,3691,3697,3701,3709,3719,3727,3733,3739,3761,3767,3769,3779,3793,3797,3803,3821,3823,3833,3847,3851,3853,3863,3877,3881,3889,3907,3911,3917,3919,3923,3929,3931,3943,3947,3967,3989,4001,4003,4007,4013,4019,4021,4027,4049,4051,4057,4073,4079,4091,4093,4099,4111,4127,4129,4133,4139,4153,4157,4159,4177,4201,4211,4217,4219,4229,4231,4241,4243,4253,4259,4261,4271,4273,4283,4289,4297,4327,4337,4339,4349,4357,4363,4373,4391,4397,4409,4421,4423,4441,4447,4451,4457,4463,4481,4483,4493,4507,4513,4517,4519,4523,4547,4549,4561,4567,4583,4591,4597,4603,4621,4637,4639,4643,4649,4651,4657,4663,4673,4679,4691,4703,4721,4723,4729,4733,4751,4759,4783,4787,4789,4793,4799,4801,4813,4817,4831,4861,4871,4877,4889,4903,4909,4919,4931,4933,4937,4943,4951,4957,4967,4969,4973,4987,4993,4999,5003,5009,5011,5021,5023,5039,5051,5059,5077,5081,5087,5099,5101,5107,5113,5119,5147,5153,5167,5171,5179,5189,5197,5209,5227,5231,5233,5237,5261,5273,5279,5281,5297,5303,5309,5323,5333,5347,5351,5381,5387,5393,5399,5407,5413,5417,5419,5431,5437,5441,5443,5449,5471,5477,5479,5483,5501,5503,5507,5519,5521,5527,5531,5557,5563,5569,5573,5581,5591,5623,5639,5641,5647,5651,5653,5657,5659,5669,5683,5689,5693,5701,5711,5717,5737,5741,5743,5749,5779,5783,5791,5801,5807,5813,5821,5827,5839,5843,5849,5851,5857,5861,5867,5869,5879,5881,5897,5903,5923,5927,5939,5953,5981,5987,6007,6011,6029,6037,6043,6047,6053,6067,6073,6079,6089,6091,6101,6113,6121,6131,6133,6143,6151,6163,6173,6197,6199,6203,6211,6217,6221,6229,6247,6257,6263,6269,6271,6277,6287,6299,6301,6311,6317,6323,6329,6337,6343,6353,6359,6361,6367,6373,6379,6389,6397,6421,6427,6449,6451,6469,6473,6481,6491,6521,6529,6547,6551,6553,6563,6569,6571,6577,6581,6599,6607,6619,6637,6653,6659,6661,6673,6679,6689,6691,6701,6703,6709,6719,6733,6737,6761,6763,6779,6781,6791,6793,6803,6823,6827,6829,6833,6841,6857,6863,6869,6871,6883,6899,6907,6911,6917,6947,6949,6959,6961,6967,6971,6977,6983,6991,6997,7001,7013,7019,7027,7039,7043,7057,7069,7079,7103,7109,7121,7127,7129,7151,7159,7177,7187,7193,7207,7211,7213,7219,7229,7237,7243,7247,7253,7283,7297,7307,7309,7321,7331,7333,7349,7351,7369,7393,7411,7417,7433,7451,7457,7459,7477,7481,7487,7489,7499,7507,7517,7523,7529,7537,7541,7547,7549,7559,7561,7573,7577,7583,7589,7591,7603,7607,7621,7639,7643,7649,7669,7673,7681,7687,7691,7699,7703,7717,7723,7727,7741,7753,7757,7759,7789,7793,7817,7823,7829,7841,7853,7867,7873,7877,7879,7883,7901,7907,7919,7927,7933,7937,7949,7951,7963,7993,8009,8011,8017,8039,8053,8059,8069,8081,8087,8089,8093,8101,8111,8117,8123,8147,8161,8167,8171,8179,8191,8209,8219,8221,8231,8233,8237,8243,8263,8269,8273,8287,8291,8293,8297,8311,8317,8329,8353,8363,8369,8377,8387,8389,8419,8423,8429,8431,8443,8447,8461,8467,8501,8513,8521,8527,8537,8539,8543,8563,8573,8581,8597,8599,8609,8623,8627,8629,8641,8647,8663,8669,8677,8681,8689,8693,8699,8707,8713,8719,8731,8737,8741,8747,8753,8761,8779,8783,8803,8807,8819,8821,8831,8837,8839,8849,8861,8863,8867,8887,8893,8923,8929,8933,8941,8951,8963,8969,8971,8999,9001,9007,9011,9013,9029,9041,9043,9049,9059,9067,9091,9103,9109,9127,9133,9137,9151,9157,9161,9173,9181,9187,9199,9203,9209,9221,9227,9239,9241,9257,9277,9281,9283,9293,9311,9319,9323,9337,9341,9343,9349,9371,9377,9391,9397,9403,9413,9419,9421,9431,9433,9437,9439,9461,9463,9467,9473,9479,9491,9497,9511,9521,9533,9539,9547,9551,9587,9601,9613,9619,9623,9629,9631,9643,9649,9661,9677,9679,9689,9697,9719,9721,9733,9739,9743,9749,9767,9769,9781,9787,9791,9803,9811,9817,9829,9833,9839,9851,9857,9859,9871,9883,9887,9901,9907,9923,9929,9931,9941,9949,9967,9973};
  private static HashSet<int> tens = new HashSet<int> {
   -10000,-9990,-9980,-9970,-9960,-9950,-9940,-9930,-9920,-9910,-9900,-9890,-9880,-9870,-9860,-9850,-9840,-9830,-9820,-9810,-9800,-9790,-9780,-9770,-9760,-9750,-9740,-9730,-9720,-9710,-9700,-9690,-9680,-9670,-9660,-9650,-9640,-9630,-9620,-9610,-9600,-9590,-9580,-9570,-9560,-9550,-9540,-9530,-9520,-9510,-9500,-9490,-9480,-9470,-9460,-9450,-9440,-9430,-9420,-9410,-9400,-9390,-9380,-9370,-9360,-9350,-9340,-9330,-9320,-9310,-9300,-9290,-9280,-9270,-9260,-9250,-9240,-9230,-9220,-9210,-9200,-9190,-9180,-9170,-9160,-9150,-9140,-9130,-9120,-9110,-9100,-9090,-9080,-9070,-9060,-9050,-9040,-9030,-9020,-9010,-9000,-8990,-8980,-8970,-8960,-8950,-8940,-8930,-8920,-8910,-8900,-8890,-8880,-8870,-8860,-8850,-8840,-8830,-8820,-8810,-8800,-8790,-8780,-8770,-8760,-8750,-8740,-8730,-8720,-8710,-8700,-8690,-8680,-8670,-8660,-8650,-8640,-8630,-8620,-8610,-8600,-8590,-8580,-8570,-8560,-8550,-8540,-8530,-8520,-8510,-8500,-8490,-8480,-8470,-8460,-8450,-8440,-8430,-8420,-8410,-8400,-8390,-8380,-8370,-8360,-8350,-8340,-8330,-8320,-8310,-8300,-8290,-8280,-8270,-8260,-8250,-8240,-8230,-8220,-8210,-8200,-8190,-8180,-8170,-8160,-8150,-8140,-8130,-8120,-8110,-8100,-8090,-8080,-8070,-8060,-8050,-8040,-8030,-8020,-8010,-8000,-7990,-7980,-7970,-7960,-7950,-7940,-7930,-7920,-7910,-7900,-7890,-7880,-7870,-7860,-7850,-7840,-7830,-7820,-7810,-7800,-7790,-7780,-7770,-7760,-7750,-7740,-7730,-7720,-7710,-7700,-7690,-7680,-7670,-7660,-7650,-7640,-7630,-7620,-7610,-7600,-7590,-7580,-7570,-7560,-7550,-7540,-7530,-7520,-7510,-7500,-7490,-7480,-7470,-7460,-7450,-7440,-7430,-7420,-7410,-7400,-7390,-7380,-7370,-7360,-7350,-7340,-7330,-7320,-7310,-7300,-7290,-7280,-7270,-7260,-7250,-7240,-7230,-7220,-7210,-7200,-7190,-7180,-7170,-7160,-7150,-7140,-7130,-7120,-7110,-7100,-7090,-7080,-7070,-7060,-7050,-7040,-7030,-7020,-7010,-7000,-6990,-6980,-6970,-6960,-6950,-6940,-6930,-6920,-6910,-6900,-6890,-6880,-6870,-6860,-6850,-6840,-6830,-6820,-6810,-6800,-6790,-6780,-6770,-6760,-6750,-6740,-6730,-6720,-6710,-6700,-6690,-6680,-6670,-6660,-6650,-6640,-6630,-6620,-6610,-6600,-6590,-6580,-6570,-6560,-6550,-6540,-6530,-6520,-6510,-6500,-6490,-6480,-6470,-6460,-6450,-6440,-6430,-6420,-6410,-6400,-6390,-6380,-6370,-6360,-6350,-6340,-6330,-6320,-6310,-6300,-6290,-6280,-6270,-6260,-6250,-6240,-6230,-6220,-6210,-6200,-6190,-6180,-6170,-6160,-6150,-6140,-6130,-6120,-6110,-6100,-6090,-6080,-6070,-6060,-6050,-6040,-6030,-6020,-6010,-6000,-5990,-5980,-5970,-5960,-5950,-5940,-5930,-5920,-5910,-5900,-5890,-5880,-5870,-5860,-5850,-5840,-5830,-5820,-5810,-5800,-5790,-5780,-5770,-5760,-5750,-5740,-5730,-5720,-5710,-5700,-5690,-5680,-5670,-5660,-5650,-5640,-5630,-5620,-5610,-5600,-5590,-5580,-5570,-5560,-5550,-5540,-5530,-5520,-5510,-5500,-5490,-5480,-5470,-5460,-5450,-5440,-5430,-5420,-5410,-5400,-5390,-5380,-5370,-5360,-5350,-5340,-5330,-5320,-5310,-5300,-5290,-5280,-5270,-5260,-5250,-5240,-5230,-5220,-5210,-5200,-5190,-5180,-5170,-5160,-5150,-5140,-5130,-5120,-5110,-5100,-5090,-5080,-5070,-5060,-5050,-5040,-5030,-5020,-5010,-5000,-4990,-4980,-4970,-4960,-4950,-4940,-4930,-4920,-4910,-4900,-4890,-4880,-4870,-4860,-4850,-4840,-4830,-4820,-4810,-4800,-4790,-4780,-4770,-4760,-4750,-4740,-4730,-4720,-4710,-4700,-4690,-4680,-4670,-4660,-4650,-4640,-4630,-4620,-4610,-4600,-4590,-4580,-4570,-4560,-4550,-4540,-4530,-4520,-4510,-4500,-4490,-4480,-4470,-4460,-4450,-4440,-4430,-4420,-4410,-4400,-4390,-4380,-4370,-4360,-4350,-4340,-4330,-4320,-4310,-4300,-4290,-4280,-4270,-4260,-4250,-4240,-4230,-4220,-4210,-4200,-4190,-4180,-4170,-4160,-4150,-4140,-4130,-4120,-4110,-4100,-4090,-4080,-4070,-4060,-4050,-4040,-4030,-4020,-4010,-4000,-3990,-3980,-3970,-3960,-3950,-3940,-3930,-3920,-3910,-3900,-3890,-3880,-3870,-3860,-3850,-3840,-3830,-3820,-3810,-3800,-3790,-3780,-3770,-3760,-3750,-3740,-3730,-3720,-3710,-3700,-3690,-3680,-3670,-3660,-3650,-3640,-3630,-3620,-3610,-3600,-3590,-3580,-3570,-3560,-3550,-3540,-3530,-3520,-3510,-3500,-3490,-3480,-3470,-3460,-3450,-3440,-3430,-3420,-3410,-3400,-3390,-3380,-3370,-3360,-3350,-3340,-3330,-3320,-3310,-3300,-3290,-3280,-3270,-3260,-3250,-3240,-3230,-3220,-3210,-3200,-3190,-3180,-3170,-3160,-3150,-3140,-3130,-3120,-3110,-3100,-3090,-3080,-3070,-3060,-3050,-3040,-3030,-3020,-3010,-3000,-2990,-2980,-2970,-2960,-2950,-2940,-2930,-2920,-2910,-2900,-2890,-2880,-2870,-2860,-2850,-2840,-2830,-2820,-2810,-2800,-2790,-2780,-2770,-2760,-2750,-2740,-2730,-2720,-2710,-2700,-2690,-2680,-2670,-2660,-2650,-2640,-2630,-2620,-2610,-2600,-2590,-2580,-2570,-2560,-2550,-2540,-2530,-2520,-2510,-2500,-2490,-2480,-2470,-2460,-2450,-2440,-2430,-2420,-2410,-2400,-2390,-2380,-2370,-2360,-2350,-2340,-2330,-2320,-2310,-2300,-2290,-2280,-2270,-2260,-2250,-2240,-2230,-2220,-2210,-2200,-2190,-2180,-2170,-2160,-2150,-2140,-2130,-2120,-2110,-2100,-2090,-2080,-2070,-2060,-2050,-2040,-2030,-2020,-2010,-2000,-1990,-1980,-1970,-1960,-1950,-1940,-1930,-1920,-1910,-1900,-1890,-1880,-1870,-1860,-1850,-1840,-1830,-1820,-1810,-1800,-1790,-1780,-1770,-1760,-1750,-1740,-1730,-1720,-1710,-1700,-1690,-1680,-1670,-1660,-1650,-1640,-1630,-1620,-1610,-1600,-1590,-1580,-1570,-1560,-1550,-1540,-1530,-1520,-1510,-1500,-1490,-1480,-1470,-1460,-1450,-1440,-1430,-1420,-1410,-1400,-1390,-1380,-1370,-1360,-1350,-1340,-1330,-1320,-1310,-1300,-1290,-1280,-1270,-1260,-1250,-1240,-1230,-1220,-1210,-1200,-1190,-1180,-1170,-1160,-1150,-1140,-1130,-1120,-1110,-1100,-1090,-1080,-1070,-1060,-1050,-1040,-1030,-1020,-1010,-1000,-990,-980,-970,-960,-950,-940,-930,-920,-910,-900,-890,-880,-870,-860,-850,-840,-830,-820,-810,-800,-790,-780,-770,-760,-750,-740,-730,-720,-710,-700,-690,-680,-670,-660,-650,-640,-630,-620,-610,-600,-590,-580,-570,-560,-550,-540,-530,-520,-510,-500,-490,-480,-470,-460,-450,-440,-430,-420,-410,-400,-390,-380,-370,-360,-350,-340,-330,-320,-310,-300,-290,-280,-270,-260,-250,-240,-230,-220,-210,-200,-190,-180,-170,-160,-150,-140,-130,-120,-110,-100,-90,-80,-70,-60,-50,-40,-30,-20,-10,0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500,510,520,530,540,550,560,570,580,590,600,610,620,630,640,650,660,670,680,690,700,710,720,730,740,750,760,770,780,790,800,810,820,830,840,850,860,870,880,890,900,910,920,930,940,950,960,970,980,990,1000,1010,1020,1030,1040,1050,1060,1070,1080,1090,1100,1110,1120,1130,1140,1150,1160,1170,1180,1190,1200,1210,1220,1230,1240,1250,1260,1270,1280,1290,1300,1310,1320,1330,1340,1350,1360,1370,1380,1390,1400,1410,1420,1430,1440,1450,1460,1470,1480,1490,1500,1510,1520,1530,1540,1550,1560,1570,1580,1590,1600,1610,1620,1630,1640,1650,1660,1670,1680,1690,1700,1710,1720,1730,1740,1750,1760,1770,1780,1790,1800,1810,1820,1830,1840,1850,1860,1870,1880,1890,1900,1910,1920,1930,1940,1950,1960,1970,1980,1990,2000,2010,2020,2030,2040,2050,2060,2070,2080,2090,2100,2110,2120,2130,2140,2150,2160,2170,2180,2190,2200,2210,2220,2230,2240,2250,2260,2270,2280,2290,2300,2310,2320,2330,2340,2350,2360,2370,2380,2390,2400,2410,2420,2430,2440,2450,2460,2470,2480,2490,2500,2510,2520,2530,2540,2550,2560,2570,2580,2590,2600,2610,2620,2630,2640,2650,2660,2670,2680,2690,2700,2710,2720,2730,2740,2750,2760,2770,2780,2790,2800,2810,2820,2830,2840,2850,2860,2870,2880,2890,2900,2910,2920,2930,2940,2950,2960,2970,2980,2990,3000,3010,3020,3030,3040,3050,3060,3070,3080,3090,3100,3110,3120,3130,3140,3150,3160,3170,3180,3190,3200,3210,3220,3230,3240,3250,3260,3270,3280,3290,3300,3310,3320,3330,3340,3350,3360,3370,3380,3390,3400,3410,3420,3430,3440,3450,3460,3470,3480,3490,3500,3510,3520,3530,3540,3550,3560,3570,3580,3590,3600,3610,3620,3630,3640,3650,3660,3670,3680,3690,3700,3710,3720,3730,3740,3750,3760,3770,3780,3790,3800,3810,3820,3830,3840,3850,3860,3870,3880,3890,3900,3910,3920,3930,3940,3950,3960,3970,3980,3990,4000,4010,4020,4030,4040,4050,4060,4070,4080,4090,4100,4110,4120,4130,4140,4150,4160,4170,4180,4190,4200,4210,4220,4230,4240,4250,4260,4270,4280,4290,4300,4310,4320,4330,4340,4350,4360,4370,4380,4390,4400,4410,4420,4430,4440,4450,4460,4470,4480,4490,4500,4510,4520,4530,4540,4550,4560,4570,4580,4590,4600,4610,4620,4630,4640,4650,4660,4670,4680,4690,4700,4710,4720,4730,4740,4750,4760,4770,4780,4790,4800,4810,4820,4830,4840,4850,4860,4870,4880,4890,4900,4910,4920,4930,4940,4950,4960,4970,4980,4990,5000,5010,5020,5030,5040,5050,5060,5070,5080,5090,5100,5110,5120,5130,5140,5150,5160,5170,5180,5190,5200,5210,5220,5230,5240,5250,5260,5270,5280,5290,5300,5310,5320,5330,5340,5350,5360,5370,5380,5390,5400,5410,5420,5430,5440,5450,5460,5470,5480,5490,5500,5510,5520,5530,5540,5550,5560,5570,5580,5590,5600,5610,5620,5630,5640,5650,5660,5670,5680,5690,5700,5710,5720,5730,5740,5750,5760,5770,5780,5790,5800,5810,5820,5830,5840,5850,5860,5870
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值