Fibonacci:

#include<stdio.h>
int main(){
	int input,fi=1,count=0,temp;
	printf("How many steps will it print?");
	scanf("%d",&input);
	for(int i=0;i!=input;i++){
		temp=count;
		count=fi;
		printf("%d ",count);
		fi+=temp;
	}
	return 0;
}

Prime number:

#include<stdio.h>
int main(){
	int prime,k=0;
	printf("the number you think is prime;");
	scanf("%d",&prime);
	for(int i=0;i!=prime;i++){
		if(prime%i==0){
			k++;
		}
	}
	if (k!=0){
		printf("\nnumber %d is not prime",prime);
	}
	else{
		printf("\nnumber %d is prime",prime);
	}
	return 0;
}

Perfect number:

#include<stdio.h>
int main(){
	int perfect,temp;
	printf("the number you think is prime number;");
	scanf("%d",&perfect);
	for(int i=2;i!=perfect;i++){
		if(perfect%i==0){
			temp=temp+i;
		}
	}
	if(temp+1==perfect){
		printf("\n%d is a perfect number");
		}
	else{
		printf("\n%d isn't a perfect number");
	}
	return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *