C Program to print 1,4,7,10,13… series up to N

//C Program to print 1,4,7,10,13… series up to N
#include<stdio.h>
int main()
{
	int a;
 	int i;

	printf("Enter Last Number : ");
 	scanf("%d",&a);
 	for(i=0;i<=a;i++)
 	{
 		if(i%3==1)
 		{
 			printf("%d,",i);
		}
	 }		
 	return 0;
}

Output :
Enter Last Number : 25
1,4,7,10,13,16,19,22,25,



Leave a comment