import java.util.Scanner;
public class Summer{
public static void main (String[]args){
int sum=0;
for(int i=1; i<=50; i++){
System.out.println("Enter the number (50 times)");
Scanner kb = new Scanner (System.in);
int input=kb.nextInt();
sum+=input;
}
System.out.println("The sum" +sum);
}
}
#include#includebool is_prime(unsigned num) {unsigned max, factor;if (num
#!/usr/bin/perl print factorial($ARGV[11]); sub factorial { my($num) = @_; if($num == 1) { return 1; # stop at 1, factorial doesn't multiply times zero } else { return $num * factorial($num - 1); # call factorial function recursively } }
(defun prime (num) (if (< 2 num) (do ((dividend 2 (1 + dividend)) (chk-to (sqrt num))) ((equal (rem num dividend) 0)) (when (<= chk-to dividend) (return t))) t))
#include<stdio.h> #include<conio.h> int main () { int num; printf("enter the number"); scanf("%d",&num); if(num<0) num=(-1)*num; printf("absolute value=%d",num); getch(); return 0; }
num = InputBox("Enter a number: ","PROGRAM: Square") sumSquare = CInt(num) * CInt(num) MsgBox("The square of " & num & " = " & sumSquare) ===== *NOTE*: The function CInt() is what we use to convert a text string to become a numeric integer value.
public class Main{ public static void main(String[] args){ System.out.println("the factorial of 5 is: " + getFactorial(5)); } public static int getFactorial(int num){ return num + getFactorial(num-1); } }
#include<stdio.h> #include<conio.h> void main() { int num; for(num=1;num<=100;num++) { printf("%d",num); } getch(); }
Implement an isPrime method int JAVA with this: int count = 0, num = 2; while(count < 50) { if(isPrime(num)) count++; num++; }
unsigned binary_to_gray (unsigned num) { return num ^ (num >> 1); } unsigned gray_to_binary (unsigned num) { /* note: assumes num is no more than 32-bits in length */ num ^= (num >> 16); num ^= (num >> 8); num ^= (num >> 4); num ^= (num >> 2); num ^= (num >> 1); return num ; }
#include#includebool is_prime(unsigned num) {unsigned max, factor;if (num
#!/usr/bin/perl print factorial($ARGV[11]); sub factorial { my($num) = @_; if($num == 1) { return 1; # stop at 1, factorial doesn't multiply times zero } else { return $num * factorial($num - 1); # call factorial function recursively } }
C:#includeint main(){int num,sum,avg=0,i;printf("enter a number");scanf("%d",&num);for(i=0;i
(defun prime (num) (if (< 2 num) (do ((dividend 2 (1 + dividend)) (chk-to (sqrt num))) ((equal (rem num dividend) 0)) (when (<= chk-to dividend) (return t))) t))
unsigned reverse (unsigned num) { unsigned rev = 0; while (num) { rev *= 10; rev += num % 10; num /= 10; } return rev; }
there could be a part in it like this: int num, digit; int count [10]; do { digit = num%10; num != 10; ++count[digit]; } while (num);
#include<stdio.h> #include<conio.h> int main () { int num; printf("enter the number"); scanf("%d",&num); if(num<0) num=(-1)*num; printf("absolute value=%d",num); getch(); return 0; }
// num = the highest number to start with final int num = 5; // Go through each value from num through 1. for (int n = num; n > 0; --n) { // For each value, print each value from num all the way down to the value. for (int m = num; m >= n; --m) { System.out.print(m); System.out.print(' '); } }