
给定一个数字N,我们需要找到第N个偶数。
偶数是能够被2整除且余数为零的数字。例如2、4、6、8、10等。
如果我们仔细观察偶数列表,我们也可以表示它们为
2*1=2, 2*2=4, 2*3=6, 2*4=8,...2*N。
因此,为了解决这个问题,我们可以简单地将数字N乘以2,这样结果就是能够被2整除的数字,即偶数。
Input: n = 4 Output: 8 The first 4 even numbers will be 2, 4, 6, 8, .. Input: n = 10 Output: 20
START STEP 1-> DECLARE AND SET n AS 10 STEP 2-> PRINT n*2 NUMBER STOP
#include <stdio.h>
int main(int argc, char const *argv[]){
int n = 10;
printf("Nth even will be:%d", n*2);
return 0;
}Nth even will be:20
以上就是C程序求第n个偶数的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号