Algorithm
Remaining 2
Adapted by Neilor Tonin, URI Brazil
Read an integer N. Print all numbers between 1 and 10000, which divided by N will give the rest = 2.
Input
The input is an integer N (N < 10000)
Output
Print all numbers between 1 and 10000, which divided by n will give the rest = 2, one per line.
Input Sample | Output Sample |
13 |
2 |
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include <stdio.h>
int main()
{
int n, i;
scanf("%i", &n);
for (i = 1; i < = 10000; ++i)
{
if(i % n == 2){
printf("%in", i);
}
}
return 0;
}
Copy The Code &
Try With Live Editor
Input
Output
#2 Code Example with C++ Programming
Code -
C++ Programming
#include <cstdio>
int main()
{
int n;
scanf("%i", &n);
for (int i = 1; i < = 10000; ++i)
{
if(i % n == 2){
printf("%in", i);
}
}
return 0;
}
Copy The Code &
Try With Live Editor
Input
Output
#3 Code Example with Java Programming
Code -
Java Programming
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int N;
Scanner input =new Scanner(System.in);
N =input.nextInt();
for (int i = 0; ((N*i) + 2) < 10000; i++) {
System.out.print((N*i) + 2+"n");
}
}
}
Copy The Code &
Try With Live Editor
Input
Output
#4 Code Example with Python Programming
Code -
Python Programming
n=int(input())
for i in range(1,10000):
if(i%n==2):
print(i)
Copy The Code &
Try With Live Editor
Input
Output