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