给定数字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